class Spyke::Attributes

Public Instance Methods

to_params() click to toggle source
# File lib/spyke/attributes.rb, line 3
def to_params
  each_with_object({}) do |(key, value), parameters|
    parameters[key] = parse_value(value)
  end.with_indifferent_access
end

Private Instance Methods

parse_value(value) click to toggle source
# File lib/spyke/attributes.rb, line 11
def parse_value(value)
  case
  when value.is_a?(Spyke::Base)         then value.attributes.to_params
  when value.is_a?(Array)               then value.map { |v| parse_value(v) }
  when value.respond_to?(:content_type) then Faraday::UploadIO.new(value.path, value.content_type)
  else value
  end
end