Method: Decanter::Core::ClassMethods#input

Defined in:
lib/decanter/core.rb

#input(name, parsers = nil, **options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/decanter/core.rb', line 10

def input(name, parsers=nil, **options)

  _name = [name].flatten

  if _name.length > 1 && parsers.blank?
    raise ArgumentError.new("#{self.name} no parser specified for input with multiple values.")
  end

  handlers[_name] = {
    key:     options.fetch(:key, _name.first),
    name:    _name,
    options: options,
    parsers:  parsers,
    type:    :input
  }
end