Class: ROM::ConfigurationDSL::CommandDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/configuration_dsl/command_dsl.rb

Overview

Command ‘define` DSL used by Setup#commands

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation, adapter = nil, &block) ⇒ CommandDSL

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.

Returns a new instance of CommandDSL.



12
13
14
15
16
17
# File 'lib/rom/configuration_dsl/command_dsl.rb', line 12

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

Instance Attribute Details

#adapterObject (readonly)



9
10
11
# File 'lib/rom/configuration_dsl/command_dsl.rb', line 9

def adapter
  @adapter
end

#command_classesObject (readonly)



9
10
11
# File 'lib/rom/configuration_dsl/command_dsl.rb', line 9

def command_classes
  @command_classes
end

#relationObject (readonly)



9
10
11
# File 'lib/rom/configuration_dsl/command_dsl.rb', line 9

def relation
  @relation
end

Instance Method Details

#define(name, options = EMPTY_HASH, &block) ⇒ Class

Define a command class

Parameters:

  • name (Symbol)

    of the command

  • options (Hash) (defaults to: EMPTY_HASH)

Options Hash (options):

  • :type (Symbol)

    The type of the command

Returns:

  • (Class)

    generated class



28
29
30
31
32
# File 'lib/rom/configuration_dsl/command_dsl.rb', line 28

def define(name, options = EMPTY_HASH, &block)
  @command_classes << Command.build_class(
    name, relation, { adapter: adapter }.merge(options), &block
  )
end