Class: ROM::Finalize::FinalizeMappers
- Inherits:
-
Object
- Object
- ROM::Finalize::FinalizeMappers
- Defined in:
- core/lib/rom/setup/finalize/finalize_mappers.rb
Instance Attribute Summary collapse
-
#mapper_classes ⇒ Object
readonly
Returns the value of attribute mapper_classes.
-
#mapper_objects ⇒ Object
readonly
Returns the value of attribute mapper_objects.
-
#registry_hash ⇒ Object
readonly
Returns the value of attribute registry_hash.
Instance Method Summary collapse
-
#initialize(mapper_classes, mapper_objects) ⇒ FinalizeMappers
constructor
private
A new instance of FinalizeMappers.
- #run! ⇒ Object private
Constructor Details
#initialize(mapper_classes, mapper_objects) ⇒ FinalizeMappers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FinalizeMappers.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'core/lib/rom/setup/finalize/finalize_mappers.rb', line 11 def initialize(mapper_classes, mapper_objects) @mapper_classes = mapper_classes @mapper_objects = mapper_objects check_duplicate_registered_mappers @registry_hash = [@mapper_classes.map(&:base_relation) + @mapper_objects.keys] .flatten .uniq .each_with_object({}) { |n, h| h[n] = {} } end |
Instance Attribute Details
#mapper_classes ⇒ Object (readonly)
Returns the value of attribute mapper_classes.
8 9 10 |
# File 'core/lib/rom/setup/finalize/finalize_mappers.rb', line 8 def mapper_classes @mapper_classes end |
#mapper_objects ⇒ Object (readonly)
Returns the value of attribute mapper_objects.
8 9 10 |
# File 'core/lib/rom/setup/finalize/finalize_mappers.rb', line 8 def mapper_objects @mapper_objects end |
#registry_hash ⇒ Object (readonly)
Returns the value of attribute registry_hash.
8 9 10 |
# File 'core/lib/rom/setup/finalize/finalize_mappers.rb', line 8 def registry_hash @registry_hash end |
Instance Method Details
#run! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'core/lib/rom/setup/finalize/finalize_mappers.rb', line 24 def run! cache = Cache.new mappers = registry_hash.each_with_object({}) do |(relation_name, relation_mappers), h| relation_mappers.update(build_mappers(relation_name)) if mapper_objects.key?(relation_name) relation_mappers.update(mapper_objects[relation_name]) end h[relation_name] = MapperRegistry.new(relation_mappers, cache: cache) end Registry.new(mappers, cache: cache) end |