Граф коммитов

19 Коммитов

Автор SHA1 Сообщение Дата
shyouhei b57915eddc Add FrozenError as a subclass of RuntimeError
FrozenError will be used instead of RuntimeError for exceptions
raised when there is an attempt to modify a frozen object. The
reason for this change is to differentiate exceptions related
to frozen objects from generic exceptions such as those generated
by Kernel#raise without an exception class.

From: Jeremy Evans <code@jeremyevans.net>
Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org>


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12 00:46:34 +00:00
nobu 3c45a7899e Delegate to `eql?` [Fix GH-1564]
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object.
  based on the patch by giginet <giginet.net@gmail.com>.
  [ruby-core:76950] [Bug #12684]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-24 03:35:29 +00:00
kazu 761dd9a778 lib/delegate.rb: Specify frozen_string_literal: true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-06 02:05:35 +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
nobu bcaec55695 delegate.rb: keep special methods
* lib/delegate.rb (Delegator): keep source information methods
  which start and end with '__'.  [ruby-core:58572] [Bug #9155]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-17 11:05:03 +00:00
nobu fc4de12302 delegate.rb: ignore unset target
* lib/delegate.rb (Delegator#method_missing): ignore the target if not
  set, and delegate to global methods.  [ruby-core:58572] [Bug #9155]
* lib/delegate.rb (Delegator#respond_to_missing): ditto.
* lib/delegate.rb (SimpleDelegator#__getobj__): yield and return if
  not delegated but a block is given, like as Hash#fetch.
* lib/delegate.rb (DelegateClass#__getobj__): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-04 03:47:57 +00:00
nobu bb6607404a delegate.rb: check if target is set
* lib/delegate.rb (SimpleDelegator#__getobj__): target object must be set.
* lib/delegate.rb (DelegateClass#__getobj__): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 09:47:31 +00:00
nobu a9a6c103e5 delegate.rb: refix r43682
* lib/delegate.rb (Delegator#send): separate from method_missing so
  that super calls proper method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 16:27:40 +00:00
nobu ca5739979d delegate.rb: get rid of global function interference
* lib/delegate.rb (Delegator#send): override to get rid of global function interference.
  [Fixes GH-449]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-15 08:07:39 +00:00
naruse 6e56d645f0 * lib/delegate.rb (Delegator#methods): Kernel#methods receives
zero or one argument. [ruby-core:37118] [Bug #4882]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-04 03:05:03 +00:00
matz a7926befe0 * object.c (rb_obj_clone): call initialize_clone hook method to
call initialize_copy.

* object.c (rb_obj_dup): call initialize_dup hook.

* lib/delegate.rb (Delegator#initialize_clone): use new hook to
  implement deep copy.  [ruby-dev:40242]

* lib/delegate.rb (Delegator#initialize_dup): ditto.

* test/test_delegate.rb (TestDelegateClass#test_copy_frozen): add
  a test to ensure #clone copies frozen status.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-08 07:43:54 +00:00
nobu 26b8c0890f * test/test_delegate.rb (TestDelegateClass::IV#initialize): should
set delegation target.

* test/test_delegate.rb (TestDelegateClass#test_copy_frozen):
  clone of frozen delegator also should be frozen.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-06 02:41:04 +00:00
nobu 7873c05684 * lib/delegate.rb (Delegator): include copy of Kernel.
[ruby-dev:40314]

* lib/delegate.rb (Delegator#{dup,clone}): class of copy should be
  Delegator.  [ruby-dev:40313]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-05 07:38:10 +00:00
nobu 10e8419da6 * lib/delegate.rb (Delegator): now inherits BasicObject.
[ruby-dev:39154], [Bug #2679], [ruby-dev:40242]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-03 23:15:55 +00:00
nobu 1d10aa8bfc * marshal.c (w_object): reverted r26007. [ruby-dev:39845]
* test/test_delegate.rb (test_marshal): moved from test_marshal.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-07 05:11:10 +00:00
matz e1797bc7dd * lib/delegate.rb (Delegator::public_api): take snapshot of
public method at the beginning time.

* lib/delegate.rb (SimpleDelegator#initialize): use
  Delegator.public_api since public_method might be added after
  initialization.  [ruby-dev:39383]

* lib/delegate.rb (DelegateClass): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-06 13:07:12 +00:00
xibbar 54e2cb8179 add test for {SimpleDelegator, DelegateClass}#class .
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-18 15:18:49 +00:00
akr 796d005a23 add a test for [ruby-dev:34808].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 01:34:37 +00:00
usa 3009bcb679 * test/test_delegate.rb: add new test file for delegate.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-16 08:36:56 +00:00