Sha256: ef5495b3bf73732ed6d4c86126c4a9c1aa7720dcbb49b10bd9e3b986c2360483

Contents?: true

Size: 1.19 KB

Versions: 41

Compression:

Stored size: 1.19 KB

Contents

require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/delegation'

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}"
          @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

41 entries across 41 versions & 3 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/activesupport-3.0.0/lib/active_support/json/decoding.rb
activesupport-3.0.19 lib/active_support/json/decoding.rb
activesupport-3.0.18 lib/active_support/json/decoding.rb
activesupport-3.0.17 lib/active_support/json/decoding.rb
activesupport-3.0.16 lib/active_support/json/decoding.rb
activesupport-3.0.15 lib/active_support/json/decoding.rb
activesupport-3.0.14 lib/active_support/json/decoding.rb
activesupport-3.0.13 lib/active_support/json/decoding.rb
activesupport-3.0.13.rc1 lib/active_support/json/decoding.rb
activesupport-3.0.12 lib/active_support/json/decoding.rb
activesupport-3.0.12.rc1 lib/active_support/json/decoding.rb
activesupport-3.0.11 lib/active_support/json/decoding.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/json/decoding.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/json/decoding.rb
activesupport-3.0.10 lib/active_support/json/decoding.rb
activesupport-3.0.10.rc1 lib/active_support/json/decoding.rb
activesupport-3.0.9 lib/active_support/json/decoding.rb
activesupport-3.0.9.rc5 lib/active_support/json/decoding.rb
activesupport-3.0.9.rc4 lib/active_support/json/decoding.rb
activesupport-3.0.9.rc3 lib/active_support/json/decoding.rb