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

Version Path
depengine-0.0.11 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.11 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.10 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.10 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.9 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.9 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.8 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.8 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.7 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.7 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.5 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.5 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.4 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.4 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.3 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.3 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.2 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.2 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.1 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb
depengine-0.0.1 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/json/decoding.rb