Class: ROM::Setup
- Inherits:
-
Object
- Object
- ROM::Setup
- Defined in:
- lib/rom/setup.rb
Overview
Setup objects collect component classes during setup/finalization process
Instance Attribute Summary collapse
-
#command_classes ⇒ Array
readonly
private
Registered command subclasses.
-
#mapper_classes ⇒ Array
readonly
private
Registered mapper subclasses.
- #notifications ⇒ Object readonly private
- #plugins ⇒ Object readonly private
-
#relation_classes ⇒ Array
readonly
private
Registered relation subclasses.
Instance Method Summary collapse
-
#auto_registration(directory, options = {}) ⇒ Setup
Enable auto-registration for a given setup object.
-
#initialize(notifications) ⇒ Setup
constructor
private
A new instance of Setup.
-
#register_command(*klasses) ⇒ Object
private
Command sub-classes are being registered with this method during setup.
-
#register_mapper(*klasses) ⇒ Object
private
Mapper sub-classes are being registered with this method during setup.
- #register_plugin(plugin) ⇒ Object private
-
#register_relation(*klasses) ⇒ Object
private
Relation sub-classes are being registered with this method during setup.
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_classes ⇒ Array (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.
21 22 23 |
# File 'lib/rom/setup.rb', line 21 def command_classes @command_classes end |
#mapper_classes ⇒ Array (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.
16 17 18 |
# File 'lib/rom/setup.rb', line 16 def mapper_classes @mapper_classes end |
#notifications ⇒ Object (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 |
#plugins ⇒ Object (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_classes ⇒ Array (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.
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
47 48 49 50 51 52 53 |
# File 'lib/rom/setup.rb', line 47 def auto_registration(directory, = {}) auto_registration = AutoRegistration.new(directory, ) 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 |