class Medie::Json::Driver
Receives Json
representations and turn them into hashes. Turn hashes into json objects.
Public Instance Methods
can_handle?(content_type)
click to toggle source
# File lib/medie/json/driver.rb, line 22 def can_handle?(content_type) !(content_type.nil? || content_type.split(";")[0]!="application/json") end
marshal(obj, rel)
click to toggle source
# File lib/medie/json/driver.rb, line 6 def marshal(obj, rel) if obj.kind_of? String obj else obj.to_json end end
unmarshal(content)
click to toggle source
# File lib/medie/json/driver.rb, line 14 def unmarshal(content) if content.nil? return {}.extend(Methodize).extend(Linked).use_link_type(Medie::Json::Links) end ::JSON.parse(content).extend(Methodize).extend(Linked).use_link_type(Medie::Json::Links) end