Class: ROM::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/setup.rb

Overview

Setup objects collect component classes during setup/finalization process

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(notifications) ⇒ Setup

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 Setup.



30
31
32
33
34
35
36
# File 'lib/rom/setup.rb', line 30

def initialize(notifications)
  @relation_classes = []
  @command_classes = []
  @mapper_classes = []
  @plugins = []
  @notifications = notifications
end

Instance Attribute Details

#command_classesArray (readonly)

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 registered command subclasses.

Returns:

  • (Array)

    registered command subclasses



21
22
23
# File 'lib/rom/setup.rb', line 21

def command_classes
  @command_classes
end

#mapper_classesArray (readonly)

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 registered mapper subclasses.

Returns:

  • (Array)

    registered mapper subclasses



16
17
18
# File 'lib/rom/setup.rb', line 16

def mapper_classes
  @mapper_classes
end

#notificationsObject (readonly)

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.



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

def notifications
  @notifications
end

#pluginsObject (readonly)

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.



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

def plugins
  @plugins
end

#relation_classesArray (readonly)

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 registered relation subclasses.

Returns:

  • (Array)

    registered relation subclasses



11
12
13
# File 'lib/rom/setup.rb', line 11

def relation_classes
  @relation_classes
end

Instance Method Details

#auto_registration(directory, options = {}) ⇒ Setup

Enable auto-registration for a given setup object

Parameters:

  • directory (String, Pathname)

    The root path to components

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :namespace (Boolean, String)

    Enable/disable namespace or provide a custom namespace name

Returns:



47
48
49
50
51
52
53
# File 'lib/rom/setup.rb', line 47

def auto_registration(directory, options = {})
  auto_registration = AutoRegistration.new(directory, options)
  auto_registration.relations.map { |r| register_relation(r) }
  auto_registration.commands.map { |r| register_command(r) }
  auto_registration.mappers.map { |r| register_mapper(r) }
  self
end

#register_command(*klasses) ⇒ Object

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.

Command sub-classes are being registered with this method during setup



72
73
74
# File 'lib/rom/setup.rb', line 72

def register_command(*klasses)
  klasses.reduce(@command_classes, :<<)
end

#register_mapper(*klasses) ⇒ Object

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.

Mapper sub-classes are being registered with this method during setup



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

def register_mapper(*klasses)
  klasses.reduce(@mapper_classes, :<<)
end

#register_plugin(plugin) ⇒ Object

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.



77
78
79
# File 'lib/rom/setup.rb', line 77

def register_plugin(plugin)
  plugins << plugin
end

#register_relation(*klasses) ⇒ Object

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.

Relation sub-classes are being registered with this method during setup



58
59
60
# File 'lib/rom/setup.rb', line 58

def register_relation(*klasses)
  klasses.reduce(@relation_classes, :<<)
end