Sha256: bbad851614ae238514b4aa2a8d39de65b0fceb982ed2fb415b0a0263fab8007c

Contents?: true

Size: 922 Bytes

Versions: 15

Compression:

Stored size: 922 Bytes

Contents

# frozen_string_literal: true

require 'rom/configuration_dsl/command'

module ROM
  module ConfigurationDSL
    # Command `define` DSL used by Setup#commands
    #
    # @private
    class CommandDSL
      attr_reader :relation, :adapter, :command_classes

      # @api private
      def initialize(relation, adapter = nil, &block)
        @relation = relation
        @adapter = adapter
        @command_classes = []
        instance_exec(&block)
      end

      # 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(name, options = EMPTY_HASH, &block)
        @command_classes << Command.build_class(
          name, relation, { adapter: adapter }.merge(options), &block
        )
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rom-core-5.3.2 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.3.1 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.3.0 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.6 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.5 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.4 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.3 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.2 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.2.1 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.1.2 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.1.1 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.1.0 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.0.2 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.0.1 lib/rom/configuration_dsl/command_dsl.rb
rom-core-5.0.0 lib/rom/configuration_dsl/command_dsl.rb