Module: Evil::Client::Formatter::Form

Extended by:
Form
Included in:
Form
Defined in:
lib/evil/client/formatter/form.rb

Overview

Utility module to format body/query as a form

Examples:

Evil::Client::Formatter::Form.call foo: { bar: [:baz] }, qux: 1
# => "foo[bar][]=baz&qux=1"

Instance Method Summary collapse

Instance Method Details

#call(source) ⇒ String

Formats nested hash as a string

Parameters:

  • source (Hash)

Returns:

  • (String)


17
18
19
20
21
22
23
# File 'lib/evil/client/formatter/form.rb', line 17

def call(source)
  case source
  when nil  then nil
  when Hash then normalize(source)
  else raise "#{source} is not a hash"
  end
end