Class: Ni::Params::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ni/params.rb

Constant Summary collapse

CONFIG_MAP =
{
  String => :description,
  Hash   => :options,
  Proc   => :contract,
  Symbol => :method_contract
}

Class Method Summary collapse

Class Method Details

.perform(args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/ni/params.rb', line 13

def self.perform(args)
  args.each_with_object({}) do |next_arg, acc|
    option = CONFIG_MAP[next_arg.class]

    fail 'unknown argument' unless option.present?

    acc[option] = next_arg
  end
end