class ROM::Finalize
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
@private
Attributes
command_classes[R]
config[R]
gateways[R]
mapper_classes[R]
mapper_objects[R]
notifications[R]
plugins[R]
relation_classes[R]
repo_adapter[R]
Public Class Methods
new(options)
click to toggle source
@api private
# File lib/rom/setup/finalize.rb, line 30 def initialize(options) @gateways = options.fetch(:gateways) @relation_classes = options.fetch(:relation_classes) @command_classes = options.fetch(:command_classes) mappers = options.fetch(:mappers, []) @mapper_classes = mappers.select { |mapper| mapper.is_a?(Class) } @mapper_objects = (mappers - @mapper_classes).reduce(:merge) || {} @config = options.fetch(:config) @notifications = options.fetch(:notifications) @plugins = options.fetch(:plugins) end
Public Instance Methods
adapter_for(gateway)
click to toggle source
Return adapter identifier for a given gateway object
@return [Symbol]
@api private
# File lib/rom/setup/finalize.rb, line 51 def adapter_for(gateway) gateways[gateway].adapter end
run!()
click to toggle source
Run the finalization process
This creates relations, mappers and commands
@return [Container]
@api private
# File 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
Private Instance Methods
load_commands(relations)
click to toggle source
Build entire command registries
This includes both classes created via DSL and explicit definitions
@api private
# File lib/rom/setup/finalize.rb, line 101 def load_commands(relations) FinalizeCommands.new(relations, gateways, command_classes, notifications).run! end
load_mappers()
click to toggle source
@api private
# File lib/rom/setup/finalize.rb, line 92 def load_mappers FinalizeMappers.new(mapper_classes, mapper_objects).run! end
load_relations(mappers)
click to toggle source
Build entire relation registry from all known relation subclasses
This includes both classes created via DSL and explicit definitions
@api private
# File lib/rom/setup/finalize.rb, line 79 def load_relations(mappers) global_plugins = plugins.select { |p| p.type == :relation || p.type == :schema } FinalizeRelations.new( gateways, relation_classes, mappers: mappers, plugins: global_plugins, notifications: notifications ).run! end