Class: ROM::Finalize

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(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

Instance Attribute Details

#command_classesObject (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

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'core/lib/rom/setup/finalize.rb', line 25

def config
  @config
end

#gatewaysObject (readonly)

Returns the value of attribute gateways.



25
26
27
# File 'core/lib/rom/setup/finalize.rb', line 25

def gateways
  @gateways
end

#mapper_classesObject (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_objectsObject (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

#notificationsObject (readonly)

Returns the value of attribute notifications.



25
26
27
# File 'core/lib/rom/setup/finalize.rb', line 25

def notifications
  @notifications
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



25
26
27
# File 'core/lib/rom/setup/finalize.rb', line 25

def plugins
  @plugins
end

#relation_classesObject (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_adapterObject (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

Returns:

  • (Symbol)


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

Returns:



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