Class: ROM::Finalize
- Inherits:
-
Object
- Object
- ROM::Finalize
- Defined in:
- core/lib/rom/setup/finalize.rb,
core/lib/rom/setup/finalize/finalize_mappers.rb,
core/lib/rom/setup/finalize/finalize_commands.rb,
core/lib/rom/setup/finalize/finalize_relations.rb
Overview
This giant builds an container using defined classes for core parts of ROM
It is used by the setup object after it's done gathering class definitions
Defined Under Namespace
Classes: FinalizeCommands, FinalizeMappers, FinalizeRelations
Instance Attribute Summary collapse
-
#command_classes ⇒ Object
readonly
Returns the value of attribute command_classes.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#gateways ⇒ Object
readonly
Returns the value of attribute gateways.
-
#mapper_classes ⇒ Object
readonly
Returns the value of attribute mapper_classes.
-
#mapper_objects ⇒ Object
readonly
Returns the value of attribute mapper_objects.
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
-
#relation_classes ⇒ Object
readonly
Returns the value of attribute relation_classes.
-
#repo_adapter ⇒ Object
readonly
Returns the value of attribute repo_adapter.
Instance Method Summary collapse
-
#adapter_for(gateway) ⇒ Symbol
private
Return adapter identifier for a given gateway object.
-
#initialize(options) ⇒ Finalize
constructor
private
A new instance of Finalize.
-
#run! ⇒ Container
private
Run the finalization process.
Constructor Details
#initialize(options) ⇒ Finalize
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 Finalize.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'core/lib/rom/setup/finalize.rb', line 30 def initialize() @gateways = .fetch(:gateways) @relation_classes = .fetch(:relation_classes) @command_classes = .fetch(:command_classes) mappers = .fetch(:mappers, []) @mapper_classes = mappers.select { |mapper| mapper.is_a?(Class) } @mapper_objects = (mappers - @mapper_classes).reduce(:merge) || {} @config = .fetch(:config) @notifications = .fetch(:notifications) @plugins = .fetch(:plugins) end |
Instance Attribute Details
#command_classes ⇒ Object (readonly)
Returns the value of attribute command_classes.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def command_classes @command_classes end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def config @config end |
#gateways ⇒ Object (readonly)
Returns the value of attribute gateways.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def gateways @gateways end |
#mapper_classes ⇒ Object (readonly)
Returns the value of attribute mapper_classes.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def mapper_classes @mapper_classes end |
#mapper_objects ⇒ Object (readonly)
Returns the value of attribute mapper_objects.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def mapper_objects @mapper_objects end |
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def notifications @notifications end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def plugins @plugins end |
#relation_classes ⇒ Object (readonly)
Returns the value of attribute relation_classes.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def relation_classes @relation_classes end |
#repo_adapter ⇒ Object (readonly)
Returns the value of attribute repo_adapter.
25 26 27 |
# File 'core/lib/rom/setup/finalize.rb', line 25 def repo_adapter @repo_adapter end |
Instance Method Details
#adapter_for(gateway) ⇒ Symbol
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.
Return adapter identifier for a given gateway object
51 52 53 |
# File 'core/lib/rom/setup/finalize.rb', line 51 def adapter_for(gateway) gateways[gateway].adapter end |
#run! ⇒ Container
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.
Run the finalization process
This creates relations, mappers and commands
62 63 64 65 66 67 68 69 70 |
# File 'core/lib/rom/setup/finalize.rb', line 62 def run! mappers = load_mappers relations = load_relations(mappers) commands = load_commands(relations) container = Container.new(gateways, relations, mappers, commands) container.freeze container end |