Module: ROM::ConfigurationDSL
- Included in:
- Configuration
- Defined in:
- lib/rom/configuration_dsl.rb,
lib/rom/configuration_dsl/command.rb,
lib/rom/configuration_dsl/relation.rb,
lib/rom/configuration_dsl/command_dsl.rb
Overview
This extends Configuration class with the DSL methods
Defined Under Namespace
Classes: Command, CommandDSL, Relation
Instance Method Summary collapse
-
#commands(name, &block) ⇒ Object
Command definition DSL.
-
#plugin(adapter, spec, &block) ⇒ Plugin
Configures a plugin for a specific adapter to be enabled for all relations.
- #plugin_registry ⇒ Object private
-
#relation(name, options = EMPTY_HASH, &block) ⇒ Object
Relation definition DSL.
Instance Method Details
#commands(name, &block) ⇒ Object
Command definition DSL
48 49 50 |
# File 'lib/rom/configuration_dsl.rb', line 48 def commands(name, &block) register_command(*CommandDSL.new(name, default_adapter, &block).command_classes) end |
#plugin(adapter, spec, &block) ⇒ Plugin
Configures a plugin for a specific adapter to be enabled for all relations
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rom/configuration_dsl.rb', line 69 def plugin(adapter, spec, &block) type, name = spec.flatten(1) plugin = plugin_registry.send(type).adapter(adapter).fetch(name) { plugin_registry.send(type).fetch(name) } if block register_plugin(plugin.configure(&block)) else register_plugin(plugin) end end |
#plugin_registry ⇒ 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.
81 82 83 |
# File 'lib/rom/configuration_dsl.rb', line 81 def plugin_registry ROM.plugin_registry end |
#relation(name, options = EMPTY_HASH, &block) ⇒ Object
Relation definition DSL
19 20 21 22 23 24 25 26 |
# File 'lib/rom/configuration_dsl.rb', line 19 def relation(name, = EMPTY_HASH, &block) klass_opts = { adapter: default_adapter }.merge() klass = Relation.build_class(name, klass_opts) klass.schema_opts(dataset: name, relation: name) klass.class_eval(&block) if block register_relation(klass) klass end |