Class: NestedRecordResolver
- Inherits:
-
Object
- Object
- NestedRecordResolver
- Includes:
- ASModel::DatabaseMapping, JSONModel
- Defined in:
- backend/app/lib/nested_record_resolver.rb
Constant Summary
Constants included from JSONModel
JSONModel::REFERENCE_KEY_REGEX
Instance Method Summary collapse
-
#initialize(nested_records, objs) ⇒ NestedRecordResolver
constructor
A new instance of NestedRecordResolver.
-
#resolve ⇒ Object
Methods included from JSONModel
JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository
Methods included from ASModel::DatabaseMapping
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
#resolve ⇒ Object
26 27 28 |
# File 'backend/app/lib/nested_record_resolver.rb', line 26 def resolve do_resolve end |