summaryrefslogtreecommitdiff
path: root/ext/json/ext/parser/parser.c
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 /ext/json/ext/parser/parser.c
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 'ext/json/ext/parser/parser.c')
-rw-r--r--ext/json/ext/parser/parser.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index 96530fb..ceb7919 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -26,7 +26,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
- i_array_class, i_key_p;
+ i_array_class, i_key_p, i_deep_const_get;
#define MinusInfinity "-Infinity"
@@ -415,7 +415,7 @@ case 26:
if (RTEST(json->create_id)) {
VALUE klassname = rb_hash_aref(*result, json->create_id);
if (!NIL_P(klassname)) {
- VALUE klass = rb_path2class(StringValueCStr(klassname));
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
*result = rb_funcall(klass, i_json_create, 1, *result);
}
@@ -1875,6 +1875,7 @@ void Init_parser()
i_object_class = rb_intern("object_class");
i_array_class = rb_intern("array_class");
i_key_p = rb_intern("key?");
+ i_deep_const_get = rb_intern("deep_const_get");
#ifdef HAVE_RUBY_ENCODING_H
mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
mEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));