Class: ROM::Setup
- Inherits:
-
Object
- Object
- ROM::Setup
- Defined in:
- core/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 'core/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 'core/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 'core/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 'core/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 'core/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 '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
49 50 51 52 53 54 55 |
# File 'core/lib/rom/setup.rb', line 49 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
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 |