aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-16 09:21:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-16 09:21:56 +0000
commite2384dd69c624555916b1162b0e7f9bd6a8480a4 (patch)
treec2e21553dc5527199a6caac0588ffb158d9be7dd /object.c
parent88757dcb007a8f9106329c85543df1beb321ecab (diff)
downloadruby-e2384dd69c624555916b1162b0e7f9bd6a8480a4.tar.gz
struct.c: dig
* object.c (rb_obj_dig): dig in nested structs too. * struct.c (rb_struct_dig): new method Struct#dig. [Feature #11688] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/object.c b/object.c
index ed5d12ea2c..5023f64b0d 100644
--- a/object.c
+++ b/object.c
@@ -3165,7 +3165,7 @@ dig_basic_p(VALUE obj, struct dig_method *cache)
VALUE
rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
{
- struct dig_method hash = {Qnil}, ary = {Qnil};
+ struct dig_method hash = {Qnil}, ary = {Qnil}, strt = {Qnil};
for (; argc > 0; ++argv, --argc) {
if (!SPECIAL_CONST_P(obj)) {
@@ -3181,6 +3181,13 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
obj = rb_ary_at(obj, *argv);
continue;
}
+ break;
+ case T_STRUCT:
+ if (dig_basic_p(obj, &strt)) {
+ obj = rb_struct_lookup(obj, *argv);
+ continue;
+ }
+ break;
}
}
return rb_check_funcall_default(obj, id_dig, argc, argv, notfound);