Class: ROM::Finalize::FinalizeCommands
- Inherits:
-
Object
- Object
- ROM::Finalize::FinalizeCommands
- Defined in:
- core/lib/rom/setup/finalize/finalize_commands.rb
Instance Attribute Summary collapse
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
Instance Method Summary collapse
-
#initialize(relations, gateways, command_classes, notifications) ⇒ FinalizeCommands
constructor
private
Build command registry hash for provided relations.
- #run! ⇒ Hash private
Constructor Details
#initialize(relations, gateways, command_classes, notifications) ⇒ FinalizeCommands
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.
Build command registry hash for provided relations
19 20 21 22 23 24 |
# File 'core/lib/rom/setup/finalize/finalize_commands.rb', line 19 def initialize(relations, gateways, command_classes, notifications) @relations = relations @gateways = gateways @command_classes = command_classes @notifications = notifications end |
Instance Attribute Details
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
10 11 12 |
# File 'core/lib/rom/setup/finalize/finalize_commands.rb', line 10 def notifications @notifications end |
Instance Method Details
#run! ⇒ Hash
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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'core/lib/rom/setup/finalize/finalize_commands.rb', line 29 def run! commands = @command_classes.map do |klass| relation = @relations[klass.relation] gateway = @gateways[relation.gateway] notifications.trigger( 'configuration.commands.class.before_build', command: klass, gateway: gateway, dataset: relation.dataset, adapter: relation.adapter ) klass.extend_for_relation(relation) if klass.restrictable klass.build(relation) end registry = Registry.new compiler = CommandCompiler.new(@gateways, @relations, registry, notifications) @relations.each do |(name, relation)| rel_commands = commands.select { |c| c.relation.name == relation.name } rel_commands.each do |command| identifier = command.class.register_as || command.class.default_name relation.commands.elements[identifier] = command end relation.commands.set_compiler(compiler) relation.commands.set_mappers(relation.mappers) registry.elements[name] = relation.commands end registry end |