Sha256: 264515fb2d101fcf1e5114eef2948bb57afc412b04bd667f75560772c6d726d7
Contents?: true
Size: 1.14 KB
Versions: 106
Compression:
Stored size: 1.14 KB
Contents
require 'active_support/core_ext/module/attribute_accessors' module ActiveSupport # Look for and parse json strings that look like ISO 8601 times. mattr_accessor :parse_json_times module JSON # Listed in order of preference. DECODERS = %w(Yajl Yaml) class << self attr_reader :parse_error delegate :decode, :to => :backend def backend set_default_backend unless defined?(@backend) @backend end def backend=(name) if name.is_a?(Module) @backend = name else require "active_support/json/backends/#{name.to_s.downcase}.rb" @backend = ActiveSupport::JSON::Backends::const_get(name) end @parse_error = @backend::ParseError end def with_backend(name) old_backend, self.backend = backend, name yield ensure self.backend = old_backend end def set_default_backend DECODERS.find do |name| begin self.backend = name true rescue LoadError # Try next decoder. false end end end end end end
Version data entries
106 entries across 76 versions & 7 rubygems