Sha256: d152fc2a2a5cad37d557a63990c3a4a82cea17fc6205a673bd11ab6fc60e825c
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true require_relative "core" module ROM module Components module DSL # Command `define` DSL used by Setup#commands # # @private class Command < Core key :commands nested(true) # Define a command class # # @param [Symbol] name of the command # @param [Hash] options # @option options [Symbol] :type The type of the command # # @return [Class] generated class # # @api public def define(id, type: id, **options, &block) command_type = inflector.classify(type) parent = adapter_namespace.const_get(command_type) constant = build_class(name: class_name(command_type), parent: parent) do |dsl| config.update(options) config.component.update(dsl.config) config.component.update(id: id, adapter: dsl.adapter) class_exec(&block) if block end call(constant: constant, config: constant.config.component) end # @api private def class_name(command_type) class_name_inferrer[ config[:relation], type: :command, inflector: inflector, adapter: adapter, command_type: command_type, class_namespace: provider.config.class_namespace ] end # @api private def adapter_namespace ROM::Command.adapter_namespace(adapter) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-6.0.0.alpha1 | lib/rom/components/dsl/command.rb |