Class: ROM::Finalize

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/setup/finalize.rb,
lib/rom/setup/finalize/finalize_mappers.rb,
lib/rom/setup/finalize/finalize_commands.rb,
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.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rom/setup/finalize.rb', line 44

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.



35
36
37
# File 'lib/rom/setup/finalize.rb', line 35

def command_classes
  @command_classes
end

#configObject (readonly)

Returns the value of attribute config.



39
40
41
# File 'lib/rom/setup/finalize.rb', line 39

def config
  @config
end

#gatewaysObject (readonly)

Returns the value of attribute gateways.



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

def gateways
  @gateways
end

#mapper_classesObject (readonly)

Returns the value of attribute mapper_classes.



31
32
33
# File 'lib/rom/setup/finalize.rb', line 31

def mapper_classes
  @mapper_classes
end

#mapper_objectsObject (readonly)

Returns the value of attribute mapper_objects.



33
34
35
# File 'lib/rom/setup/finalize.rb', line 33

def mapper_objects
  @mapper_objects
end

#notificationsObject (readonly)

Returns the value of attribute notifications.



41
42
43
# File 'lib/rom/setup/finalize.rb', line 41

def notifications
  @notifications
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



37
38
39
# File 'lib/rom/setup/finalize.rb', line 37

def plugins
  @plugins
end

#relation_classesObject (readonly)

Returns the value of attribute relation_classes.



29
30
31
# File 'lib/rom/setup/finalize.rb', line 29

def relation_classes
  @relation_classes
end

#repo_adapterObject (readonly)

Returns the value of attribute repo_adapter.



27
28
29
# File 'lib/rom/setup/finalize.rb', line 27

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)


65
66
67
# File 'lib/rom/setup/finalize.rb', line 65

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:



76
77
78
79
80
81
82
83
84
# File 'lib/rom/setup/finalize.rb', line 76

def run!
  mappers = load_mappers
  relations = load_relations(mappers)
  commands = load_commands(relations)

  container = Container.new(gateways, relations, mappers, commands)
  container.freeze
  container
end