summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2010-04-08 02:11:12 +0200
committerFlorian Frank <flori@ping.de>2010-04-08 02:33:07 +0200
commita294a83f4d22901651d09c06063eb20d3b2290b8 (patch)
treec9aeca3882c63a5891c7e5b3b89814189a2a752a /lib
parent3db50701a4a71e49709c63483d2ba4b5a408373b (diff)
downloadjson-a294a83f4d22901651d09c06063eb20d3b2290b8.tar.gz
Trigger const_missing mechanism for Rails
In order to allow Rails' dynamic class loading to work, the const_missing callback must be called.
Diffstat (limited to 'lib')
-rw-r--r--lib/json/common.rb10
-rw-r--r--lib/json/version.rb2
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/json/common.rb b/lib/json/common.rb
index 2f1584e..3ce25c1 100644
--- a/lib/json/common.rb
+++ b/lib/json/common.rb
@@ -33,12 +33,16 @@ module JSON
# level (absolute namespace path?). If there doesn't exist a constant at
# the given path, an ArgumentError is raised.
def deep_const_get(path) # :nodoc:
- path = path.to_s
- path.split(/::/).inject(Object) do |p, c|
+ path.to_s.split(/::/).inject(Object) do |p, c|
case
when c.empty? then p
when p.const_defined?(c) then p.const_get(c)
- else raise ArgumentError, "can't find const #{path}"
+ else
+ if (c = p.const_missing(c) rescue nil)
+ c
+ else
+ raise ArgumentError, "can't find const #{path}"
+ end
end
end
end
diff --git a/lib/json/version.rb b/lib/json/version.rb
index 571612e..a306929 100644
--- a/lib/json/version.rb
+++ b/lib/json/version.rb
@@ -1,6 +1,6 @@
module JSON
# JSON version
- VERSION = '1.2.3'
+ VERSION = '1.2.4'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: