A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://github.com/rails/rails/commit/63bb955a99eb46e257655c93dd64e86ebbf05651 below:

Automatically prefer Yajl or JSON backend over Yaml, if available · rails/rails@63bb955 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+18

-3

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+18

-3

lines changed Original file line number Diff line number Diff line change

@@ -1,6 +1,6 @@

1 1

*Rails 3.0 (pending)*

2 2 3 -

* JSON backend for YAJL. #2666 [Brian Lopez]

3 +

* JSON backend for YAJL. Preferred if available. #2666 [Brian Lopez]

4 4 5 5 6 6

*Rails 3.0.0 [beta] (February 4, 2010)*

Original file line number Diff line number Diff line change

@@ -6,12 +6,15 @@ module ActiveSupport

6 6

mattr_accessor :parse_json_times

7 7 8 8

module JSON

9 +

# Listed in order of preference.

10 +

DECODERS = %w(Yajl JSONGem Yaml)

11 + 9 12

class << self

10 13

attr_reader :parse_error

11 14

delegate :decode, :to => :backend

12 15 13 16

def backend

14 -

self.backend = "Yaml" unless defined?(@backend)

17 +

set_default_backend unless defined?(@backend)

15 18

@backend

16 19

end

17 20

@@ -31,6 +34,18 @@ def with_backend(name)

31 34

ensure

32 35

self.backend = old_backend

33 36

end

37 + 38 +

def set_default_backend

39 +

DECODERS.find do |name|

40 +

begin

41 +

self.backend = name

42 +

true

43 +

rescue LoadError

44 +

# Try next decoder.

45 +

false

46 +

end

47 +

end

48 +

end

34 49

end

35 50

end

36 51

end

Original file line number Diff line number Diff line change

@@ -45,7 +45,7 @@ class TestJSONDecoding < ActiveSupport::TestCase

45 45

}

46 46 47 47

# load the default JSON backend

48 -

ActiveSupport::JSON.backend

48 +

ActiveSupport::JSON.backend = 'Yaml'

49 49 50 50

backends = %w(Yaml)

51 51

backends << "JSONGem" if defined?(::JSON)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4