Class: AbstractMapper::Commands Private

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_mapper/commands.rb,
lib/abstract_mapper/commands/base.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

API:

  • private

Defined Under Namespace

Classes: Base

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:

Returns:

API:

  • private



33
34
35
36
# File 'lib/abstract_mapper/commands.rb', line 33

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

.[](name) ⇒ AbstractMapper::Commands::Base

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:

  • The name of the command

Returns:

Raises:

  • When unknown command is called

API:

  • private



47
48
49
# File 'lib/abstract_mapper/commands.rb', line 47

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.

API:

  • private



22
23
24
25
# File 'lib/abstract_mapper/commands.rb', line 22

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

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

Creates an immutable collection of commands

Parameters:

  • (defaults to: {})

Returns:



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