Marc-Andre Lafortune
f48edc28dd
Fix method protection for modules in the ancestry chain.
...
[Fixes ruby/ostruct#23 ]
2021-01-12 23:29:39 -05:00
Nobuyoshi Nakada
069649389c
strip trailing spaces [ci skip]
2021-01-06 17:34:18 +09:00
Adam Hess
e13f41e02d
[ruby/ostruct] Allow ostruct to return a value on super ( #4028 )
...
This fixes cases where you can super in something that inherits from OpenStruct
Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-01-05 18:34:45 -05:00
Marc-Andre Lafortune
6343a81129
[ruby/ostruct] Add Ractor test
2020-12-19 17:13:08 -05:00
Marc-Andre Lafortune
1486785a57
[lib/ostruct] Fix Marshal loading
2020-10-06 17:11:08 -04:00
Koichi Sasada
bc23216e5a
stop Ractor test in test-all
...
Ractor changes the interpreter's running mode so now it should
not use in test-all process which running with many other tests.
Test with a separating process is one idea, but I'm not sure
the ruby/ostruct can use this trick.
2020-10-01 08:55:08 +09:00
Marc-Andre Lafortune
b36a45c05c
[ruby/ostruct] Improved YAML serialization.
...
Patch adapted from Pietro Monteiro [Fixes bug#8382]
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
0977040133
[ruby/ostruct] Add test that frozen OpenStructs are Ractor-shareable
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
083fa6e5d2
[ruby/ostruct] Protect subclass' methods and our bang methods.
...
Internally, use only bang methods
2020-09-30 18:11:24 -04:00
Marc-Andre Lafortune
df4d08c44a
[ruby/ostruct] Avoid calling initialize
2020-09-30 18:11:24 -04:00
Yusuke Endoh
4405423c87
test/ostruct/test_ostruct.rb: Prevent "method redefined; discarding old foo"
2020-09-24 19:30:22 +09:00
Kazuhiro NISHIYAMA
e4dbb91f4c
Fix typos [ci skip]
...
s/overriden/overridden/
2020-09-17 20:34:59 +09:00
Marc-Andre Lafortune
606c009ce2
[ruby/ostruct] Avoid self calling our public methods.
...
Found because `json` has a bad example in its test suite.
This implementation still offers better encapsulation.
2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
67e5f7a9e5
[ruby/ostruct] Reinstate recent changes
...
This reverts commit 28e60b0045
.
2020-09-14 16:10:37 -04:00
Marc-Andre Lafortune
28e60b0045
[ruby/ostruct] Revert recent changes
...
This reverts commit e026e186f4..12a2e32d43.
2020-09-14 13:29:54 -04:00
Marc-Andre Lafortune
12a2e32d43
[ruby/ostruct] Add access to public instance methods in case they are overriden
2020-09-14 12:46:51 -04:00
Marc-Andre Lafortune
8eefa8f373
[ruby/ostruct] Allow overriding public methods
...
[Fixes https://bugs.ruby-lang.org/issues/15409 ]
2020-09-14 12:46:47 -04:00
Marc-Andre Lafortune
5e7ec05319
[ruby/ostruct] Add really basic test that was missing
2020-09-14 12:46:43 -04:00
Marc-Andre Lafortune
e026e186f4
[ruby/ostruct] Revert "ostruct.rb: deferred accessors"
...
This reverts commits:
dc38e99813
22c082fcfd
b499e0f9ff
58e5876646
Add test for overriden private methods
[Fixes https://bugs.ruby-lang.org/issues/12136 ]
2020-09-14 12:46:27 -04:00
Marc-Andre Lafortune
fbaab562d9
lib/ostruct.rb: Revert "To use RuntimeError instead of FrozenError for old ruby versions."
...
This reverts commit 4cd1fc8b3559353069860eee90b1b5bade013917.
2020-09-04 01:23:14 -04:00
Nobuyoshi Nakada
a504535dd4
Prefer dedicated assertion method
2020-02-25 17:47:17 +09:00
marcandre
1e30df6f77
ostruct.rb: Accept block for to_h [ #15451 ].
...
Patch by Shuji Kobayashi.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-22 17:05:03 +00:00
hsbt
1380aa04a6
Support old versions of Ruby with FrozenError.
...
They should work separatedly from Ruby core repository.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-07 12:47:11 +00:00
marcandre
b16eaf8632
lib/ostruct.rb: Use `FrozenError` instead of `RuntimeError`.
...
Patch by Yuuji Yaginuma. [Fixes GH-1808]
In other classes, `FrozenError` will be raised if change the frozen
object.
In order to match the behavior, I think that `FrozenError` should
use in `OpenStruct`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-06 23:52:30 +00:00
kazu
fc29786926
test/ostruct: Specify frozen_string_literal: true.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 23:45:33 +00:00
marcandre
e565c838ce
lib/ostruct.rb: Use frozen literals.
...
Patch adapted from Espartaco Palma. [GH-1714] [Bug #14000 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 18:08:15 +00:00
nobu
a20715c8ed
ostruct.rb: refine visibility failure message
...
* lib/ostruct.rb (method_missing): raise an exception with proper
visibility message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-28 09:21:58 +00:00
nobu
cd911b9367
ostruct.rb: fix OpenStruct.allocate
...
* lib/ostruct.rb (OpenStruct.allocate): initialize an instance
variable directly, without calling `intialize` method which may
be overridden in a subclass. [ruby-core:80292] [Bug #13358 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-24 12:16:54 +00:00
marcandre
4d7b999c77
lib/ostruct.rb: Fix returned value of each_pair.
...
From a patch by Marcus Stollsteimer. [Fixes #13169 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-03 18:25:28 +00:00
nobu
014d60ce98
test_ostruct.rb: sort method names
...
* test/ostruct/test_ostruct.rb (test_accessor_defines_method):
should not depend on the order of methods.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-04 07:47:44 +00:00
marcandre
9543908c9f
* lib/ostruct.rb: Fix case of frozen object with initializer.
...
Bug revealed by RubySpec [ruby-core:72639]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-01 17:27:38 +00:00
marcandre
2f2a5c3ae9
* lib/ostruct.rb: Fix new_ostruct_member to correctly avoid redefinition
...
[#11901 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-31 05:37:21 +00:00
nobu
15960b37e8
ostruct.rb: respond_to?
...
* 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/trunk@53366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 03:48:36 +00:00
naruse
3e92b635fb
Add frozen_string_literal: false for all files
...
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
marcandre
13d8bb0385
* lib/ostruct.rb: Have OpenStruct#dig raise if argument is not a symbol
...
nor a string. See [#11762 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12 21:40:50 +00:00
nobu
482530680c
OpenStruct#dig
...
* lib/ostruct.rb (dig): Implement OpenStruct#dig
[Feature #11688 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 05:36:03 +00:00
eregon
5389661931
* test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.
...
Patch by @jeremy in [GH-1041]: https://github.com/ruby/ruby/pull/1041
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-14 16:57:46 +00:00
nobu
759a31b4a3
Revert GH-808
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 07:07:59 +00:00
nobu
10ce99866f
ostruct.rb: append suffixes to protected methods
...
* lib/ostruct.rb (modifiable?, new_ostruct_member!, table!):
append suffixes to protected methods so that they will not clash
with assigned members. [Fix GH-806]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-05 01:57:26 +00:00
naruse
e7194e9648
Suppress warnings: ambiguous first argument; put parentheses or even spaces
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06 06:25:18 +00:00
marcandre
f9a169fff2
* lib/ostruct.rb: raise NoMethodError with a #name and #args.
...
Patch by Kenichi Kamiya. [Fixes GH-383]
* test/ostruct/test_ostruct.rb: Added tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:14:17 +00:00
marcandre
5b5de3984e
* lib/ostruct.rb (Struct#each_pair): Return an enumerator with size
...
Patch by Kenichi Kamiya. [Fixes GH-383]
* test/ostruct/test_ostruct.rb: Added tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:13:57 +00:00
marcandre
99d5d90f2f
* lib/ostruct.rb (OpenStruct#delete): Use the converted argument.
...
Patch by Kenichi Kamiya. [Fixes GH-383]
* test/ostruct/test_ostruct.rb: Added tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:13:38 +00:00
marcandre
b9e18abe4a
* lib/ostruct.rb: Raise RuntimeError when modifying frozen instances
...
instead of TypeError. Patch by Kenichi Kamiya. [Fixes GH-383]
* test/ostruct/test_ostruct.rb: Added tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:13:19 +00:00
marcandre
e44e356b53
* lib/ostruct.rb: Add [] and []=, base on a patch by Thomas Sawyer
...
[ruby-core:42779] [Feature #6056 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 21:20:10 +00:00
marcandre
3785d2675a
* lib/ostruct.rb: Also accept {Open}Struct as argument to new
...
[ruby-core:47476] [Feature #7007 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 21:19:50 +00:00
marcandre
b4300d25c9
* lib/ostruct.rb: Add OpenStruct#eql? and OpenStruct#hash
...
[ruby-core:42651] [Bug #6029 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 21:19:15 +00:00
marcandre
15d4862b91
* lib/ostruct.rb (each_pair): Add #each_pair [ #1400 ]
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-28 21:18:53 +00:00
nobu
770ddcdfe0
* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.
...
[Feature #6276 ]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 03:46:55 +00:00
marcandre
dfb1a71222
* lib/ostruct.rb (delete_field): Bug fix so previous value is returned.
...
Patch by Nick Recobra [Bug #6063 ]
* test/ostruct/test_ostruct.rb: Test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22 18:59:03 +00:00