Class: AbstractMapper::Commands Private

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_mapper/commands.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Collection of DSL commands used by the builder

Class Method Summary collapse

Class Method Details

.<<(other) ⇒ undefined

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 immutable registry with added command name and type

Parameters:

  • other ([Symbol, Class, Proc])

Returns:

  • (undefined)


31
32
33
34
# File 'lib/abstract_mapper/commands.rb', line 31

def <<(other)
  command = Command.new(*other)
  self.class.new @registry.merge(command.name => command)
end

.[](name) ⇒ AbstractMapper::Command

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 the registered command by name

Parameters:

  • name (#to_sym)

    The name of the command

Returns:

Raises:



45
46
47
# File 'lib/abstract_mapper/commands.rb', line 45

def [](name)
  @registry.fetch(name.to_sym) { fail(Errors::UnknownCommand.new name) }
end

.initialize(registry = {}) ⇒ 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.



20
21
22
23
# File 'lib/abstract_mapper/commands.rb', line 20

def initialize(registry = {})
  @registry = registry.dup
  IceNine.deep_freeze(self)
end

.new(registry = {}) ⇒ Faceter::Commands

Creates an immutable collection of commands

Parameters:

  • registry (Hash) (defaults to: {})

Returns:

  • (Faceter::Commands)


# File 'lib/abstract_mapper/commands.rb', line 11