Module: Evil::Client::Formatter
- Extended by:
- Formatter
- Included in:
- Formatter
- Defined in:
- lib/evil/client/formatter.rb,
lib/evil/client/formatter/form.rb,
lib/evil/client/formatter/part.rb,
lib/evil/client/formatter/text.rb,
lib/evil/client/formatter/multipart.rb
Overview
Utility to format body/query into one of formats: :json, :form, :multipart
Defined Under Namespace
Modules: Form, Multipart, Part, Text
Instance Method Summary collapse
-
#call(source, format, **opts) ⇒ String
Factory that knows how to format source depending on given format.
Instance Method Details
#call(source, format, **opts) ⇒ String
Factory that knows how to format source depending on given format
18 19 20 21 22 23 24 25 26 |
# File 'lib/evil/client/formatter.rb', line 18 def call(source, format, **opts) return unless source return to_json(source) if format == :json return to_yaml(source) if format == :yaml return to_form(source) if format == :form return to_text(source) if format == :text to_multipart(source, **opts) end |