Class: ROM::Setup

Inherits:
Object
  • Object
show all
Defined in:
core/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.



32
33
34
35
36
37
38
# File 'core/lib/rom/setup.rb', line 32

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



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

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



18
19
20
# File 'core/lib/rom/setup.rb', line 18

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.



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

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.



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

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



13
14
15
# File 'core/lib/rom/setup.rb', line 13

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)

Options Hash (**options):

  • :namespace (Boolean, String)

    Enable/disable namespace or provide a custom namespace name

Returns:



49
50
51
52
53
54
55
# File 'core/lib/rom/setup.rb', line 49

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



74
75
76
# File 'core/lib/rom/setup.rb', line 74

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



67
68
69
# File 'core/lib/rom/setup.rb', line 67

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.



79
80
81
# File 'core/lib/rom/setup.rb', line 79

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



60
61
62
# File 'core/lib/rom/setup.rb', line 60

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