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.
32 33 34 35 36 37 38 |
# File 'lib/rom/setup.rb', line 32 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.
23 24 25 |
# File 'lib/rom/setup.rb', line 23 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.
18 19 20 |
# File 'lib/rom/setup.rb', line 18 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.
29 30 31 |
# File 'lib/rom/setup.rb', line 29 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.
26 27 28 |
# File 'lib/rom/setup.rb', line 26 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.
13 14 15 |
# File '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
50 51 52 53 54 55 56 |
# File 'lib/rom/setup.rb', line 50 def auto_registration(directory, **) auto_registration = AutoRegistration.new(directory, **) auto_registration.relations.each { |r| register_relation(r) } auto_registration.commands.each { |r| register_command(r) } auto_registration.mappers.each { |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
75 76 77 |
# File 'lib/rom/setup.rb', line 75 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
68 69 70 |
# File 'lib/rom/setup.rb', line 68 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.
80 81 82 |
# File 'lib/rom/setup.rb', line 80 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
61 62 63 |
# File 'lib/rom/setup.rb', line 61 def register_relation(*klasses) klasses.reduce(@relation_classes, :<<) end |