Class: Net::Hippie::ContentTypeMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/net/hippie/content_type_mapper.rb

Overview

Converts a ruby hash into a JSON string

Instance Method Summary collapse

Instance Method Details

#map_from(headers, body) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/net/hippie/content_type_mapper.rb', line 7

def map_from(headers, body)
  return body if body.is_a?(String)

  content_type = headers['Content-Type'] || ''
  return JSON.generate(body) if content_type.include?('json')

  body
end