Class: NestedRecordResolver

Inherits:
Object
  • Object
show all
Defined in:
backend/app/lib/nested_record_resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(nested_records, objs) ⇒ NestedRecordResolver

Returns a new instance of NestedRecordResolver.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'backend/app/lib/nested_record_resolver.rb', line 8

def initialize(nested_records, objs)
  @nested_records = nested_records
  fully_loaded_objs = load_with_all_associations(objs).clone

  # We pull a bit of a trick here: replace the set of Sequel::Model instances
  # we were passed with an equivalent set that have all of the nested records
  # already loaded in.  That way, subsequent calls will have the data they
  # need.
  #
  # Unfortunately the current interface requires us to mutate the array
  # in-place, since there's no easy way to replace the set of objects with the
  # current sequel_to_json API.
  objs.clear
  objs.concat(fully_loaded_objs)
  @objs = objs
end

Instance Method Details

#resolveObject



26
27
28
# File 'backend/app/lib/nested_record_resolver.rb', line 26

def resolve
  do_resolve
end