Module: OEmbed::Formatter::JSON::Backends::JSONGem

Extended by:
JSONGem
Included in:
JSONGem
Defined in:
lib/oembed/formatter/json/backends/jsongem.rb

Instance Method Summary collapse

Instance Method Details

#decode(json) ⇒ Object

Parses a JSON string or IO and convert it into an object.



12
13
14
15
16
17
# File 'lib/oembed/formatter/json/backends/jsongem.rb', line 12

def decode(json)
  if json.respond_to?(:read)
    json = json.read
  end
  ::JSON.parse(json)
end

#decode_fail_msgObject



19
20
21
# File 'lib/oembed/formatter/json/backends/jsongem.rb', line 19

def decode_fail_msg
  "The version of the json library you have installed isn't parsing JSON like ruby-oembed expected."
end

#parse_errorObject



23
24
25
# File 'lib/oembed/formatter/json/backends/jsongem.rb', line 23

def parse_error
  ::JSON::ParserError
end