File: activesupportjson.rb

package info (click to toggle)
ruby-oembed 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 356 kB
  • sloc: ruby: 1,148; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Only allow this backend if ActiveSupport::JSON is already loaded
raise LoadError, "ActiveSupport::JSON isn't available. require 'activesupport/json'" unless defined?(ActiveSupport::JSON)

module OEmbed
  module Formatter
    module JSON
      module Backends
        module ActiveSupportJSON
          extend self

          # Parses a JSON string or IO and convert it into an object.
          def decode(json)
            ::ActiveSupport::JSON.decode(json)
          end
          
          def decode_fail_msg
            "The version of ActiveSupport::JSON you have installed isn't parsing JSON like ruby-oembed expected."
          end
          
          def parse_error
            ::ActiveSupport::JSON.parse_error
          end
        
        end
      end
    end
  end
end