Method: ROM::ConfigurationDSL::Command.build_class
- Defined in:
- core/lib/rom/configuration_dsl/command.rb
permalink .build_class(name, relation, options = EMPTY_HASH, &block) ⇒ 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.
Generate a command subclass
This is used by Setup#commands DSL and its define
block
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'core/lib/rom/configuration_dsl/command.rb', line 16 def self.build_class(name, relation, = EMPTY_HASH, &block) type = .fetch(:type) { name } command_type = Inflector.classify(type) adapter = .fetch(:adapter) parent = ROM::Command.adapter_namespace(adapter).const_get(command_type) class_name = generate_class_name(adapter, command_type, relation) Dry::Core::ClassBuilder.new(name: class_name, parent: parent).call do |klass| klass.register_as(name) klass.relation(relation) klass.class_eval(&block) if block end end |