class AbstractMapper::Commands
Collection of DSL
commands used by the builder
@api private
Public Class Methods
new(registry = {})
click to toggle source
@private
# File lib/abstract_mapper/commands.rb, line 22 def initialize(registry = {}) @registry = registry.dup IceNine.deep_freeze(self) end
Public Instance Methods
<<(other)
click to toggle source
Returns a new immutable registry with added command name and type
@param [[Symbol, Class, Proc]] other
@return [undefined]
# File lib/abstract_mapper/commands.rb, line 33 def <<(other) command = Base.new(*other) self.class.new @registry.merge(command.name => command) end
[](name)
click to toggle source
Returns the registered command by name
@param [#to_sym] name The name of the command
@return [AbstractMapper::Commands::Base]
@raise [AbstractMapper::Errors::UnknownCommand]
When unknown command is called
# File lib/abstract_mapper/commands.rb, line 47 def [](name) @registry.fetch(name.to_sym) { fail(Errors::UnknownCommand.new name) } end