diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 08:54:59 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-29 08:54:59 +0000 |
| commit | 4c1ac0bc07eb7ae03684761351953418ad5deb1b (patch) | |
| tree | eecb2f961856c0af1c34c3a00e79e6c4d9e2232c | |
| parent | 5d699f8a3a7ff32ebc36b7a92ececafeb81d9bab (diff) | |
merge revision(s) 53366:[Backport #11884]
* lib/ostruct.rb (OpenStruct): make respond_to? working on
just-allocated objects for workaround of Psych.
[ruby-core:72501] [Bug #11884]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | lib/ostruct.rb | 5 | ||||
| -rw-r--r-- | test/ostruct/test_ostruct.rb | 4 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Tue Mar 29 17:54:17 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/ostruct.rb (OpenStruct): make respond_to? working on + just-allocated objects for workaround of Psych. + [ruby-core:72501] [Bug #11884] + Tue Mar 29 17:04:35 2016 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm_eval.c (rb_f_catch): [DOC] fix malformed RDoc syntax, "+...+" diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 5aea0465bd..e7b8ed4609 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -71,6 +71,11 @@ # of these properties compared to using a Hash or a Struct. # class OpenStruct + # :nodoc: + class << self + alias allocate new + end + # # Creates a new OpenStruct object. By default, the resulting OpenStruct # object will have no attributes. diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 8c122b94a7..8b0424d2d8 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -23,6 +23,10 @@ class TC_OpenStruct < Test::Unit::TestCase assert_respond_to(o, :a=) end + def test_respond_to_allocated + assert_not_respond_to(OpenStruct.allocate, :a) + end + def test_equality o1 = OpenStruct.new o2 = OpenStruct.new @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.0" #define RUBY_RELEASE_DATE "2016-03-29" -#define RUBY_PATCHLEVEL 43 +#define RUBY_PATCHLEVEL 44 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 3 |
