Module: ROM::ConfigurationDSL
- Included in:
- Configuration
- Defined in:
- core/lib/rom/configuration_dsl.rb,
core/lib/rom/configuration_dsl/command.rb,
core/lib/rom/configuration_dsl/relation.rb,
core/lib/rom/configuration_dsl/mapper_dsl.rb,
core/lib/rom/configuration_dsl/command_dsl.rb
Overview
This extends Configuration class with the DSL methods
Defined Under Namespace
Classes: Command, CommandDSL, MapperDSL, Relation
Instance Method Summary collapse
-
#commands(name, &block) ⇒ Object
Command definition DSL.
-
#mappers(&block) ⇒ Object
Mapper definition DSL.
-
#plugin(adapter, spec, &block) ⇒ Plugin
Configures a plugin for a specific adapter to be enabled for all relations.
-
#relation(name, options = EMPTY_HASH, &block) ⇒ Object
Relation definition DSL.
Instance Method Details
#commands(name, &block) ⇒ Object
Command definition DSL
51 52 53 |
# File 'core/lib/rom/configuration_dsl.rb', line 51 def commands(name, &block) register_command(*CommandDSL.new(name, default_adapter, &block).command_classes) end |
#mappers(&block) ⇒ Object
Mapper definition DSL
58 59 60 |
# File 'core/lib/rom/configuration_dsl.rb', line 58 def mappers(&block) register_mapper(*MapperDSL.new(self, mapper_classes, block).mapper_classes) end |
#plugin(adapter, spec, &block) ⇒ Plugin
Configures a plugin for a specific adapter to be enabled for all relations
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'core/lib/rom/configuration_dsl.rb', line 79 def plugin(adapter, spec, &block) type, name = spec.flatten(1) plugin = plugin_registry[type].adapter(adapter).fetch(name) do plugin_registry[type].fetch(name) end if block register_plugin(plugin.configure(&block)) else register_plugin(plugin) end end |
#relation(name, options = EMPTY_HASH, &block) ⇒ Object
Relation definition DSL
22 23 24 25 26 27 28 29 |
# File 'core/lib/rom/configuration_dsl.rb', line 22 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 |