aboutsummaryrefslogtreecommitdiffstats
path: root/lib/delegate.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use caller with length to reduce unused stringskazu2017-10-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Delegate to `eql?` [Fix GH-1564]nobu2017-06-241-1/+9
| | | | | | | | * 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
* lib/delegate.rb: Specify frozen_string_literal: true.kazu2017-01-061-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: Added missing spaces and Removed needless spaces.hsbt2016-10-051-7/+7
| | | | | | [fix GH-1454][ci skip] Patch by @bogdanvlviv git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | 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
* * lib/delegate.rb: Remove backtrace cleaning for delegated methodszzak2015-09-091-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch was provided by Rafael França and greatly improves performance when an exception is raised. [Bug #11461] Before: Calculating ------------------------------------- default 86.209k i/100ms default raising 2.209k i/100ms ------------------------------------------------- default 1.953M (±11.0%) i/s - 9.655M default raising 21.826k (±13.5%) i/s - 108.241k After: Calculating ------------------------------------- default 72.211k i/100ms default raising 34.288k i/100ms ------------------------------------------------- default 2.013M (±18.7%) i/s - 9.460M default raising 623.950k (± 9.7%) i/s - 3.120M Benchmark: require 'delegate' require 'benchmark/ips' class Foo def name 'foo' end def bla raise end end class Bar < DelegateClass(Foo) end bar = Bar.new(Foo.new) Benchmark.ips do |b| b.report('default') { bar.name } b.report('default raising') { bar.bla rescue nil } end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: [DOC] Update SimpleDelegator example. [ci skip]eregon2015-06-131-5/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: fix a typo.hsbt2015-04-231-1/+1
| | | | | | [fix GH-881][ci skip] Patch by @Zorbash git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: split executable code into sample directory.hsbt2014-07-261-34/+0
| | | | | | * sample/delegate.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: [DOC] Document raise in Delegator classzzak2014-05-301-0/+6
| | | | | | | | Patch by @lucasmazza. [Fixes GH-621] https://github.com/ruby/ruby/pull/621 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: Fix example of using delegator.ayumin2014-05-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* delegate.rb: keep special methodsnobu2014-01-171-1/+1
| | | | | | | * 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
* delegate.rb: ignore unset targetnobu2013-12-041-6/+15
| | | | | | | | | | | * 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
* delegate.rb: check if target is setnobu2013-11-211-5/+10
| | | | | | | | * 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
* delegate.rb: try private methods after the targetnobu2013-11-211-14/+12
| | | | | | | * lib/delegate.rb (Delegator#method_missing): try private methods defined in Kernel after the target. [Fixes GH-449] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* delegate.rb: refix r43682nobu2013-11-191-1/+12
| | | | | | | * 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
* delegate.rb: get rid of global function interferencenobu2013-11-151-0/+1
| | | | | | | * 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
* * lib/delegate.rb: Add example for __setobj__ and __getobj__zzak2013-07-101-0/+28
| | | | | | | [Bug #8615] Patch by Caleb Thompson git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: Added documentation for Delegator#!. Patch bydrbrain2012-06-081-3/+4
| | | | | | | Zachary Scott. [ruby-trunk - Feature #6534] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#methods): Kernel#methods receivesnaruse2011-12-041-2/+2
| | | | | | 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
* * lib/delegate.rb: Move file-level documentation to the appropriatedrbrain2011-07-271-95/+76
| | | | | | | classes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: revert r31635-r31638 and untabify with expand(1).nobu2011-05-191-10/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: Convert tabs to spaces for ruby files perdrbrain2011-05-181-10/+10
| | | | | | | | | http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style Patch by Steve Klabnik [Ruby 1.9 - Bug #4730] Patch by Jason Dew [Ruby 1.9 - Feature #4718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: Forward #trust, #untrust, #taint and #untaintmarcandre2010-06-221-4/+37
| | | | | | to both the delegator and __getobj__ [ruby-core:26138] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb: Delegate !=, eql? and hash [ruby-core:26139]marcandre2010-06-121-2/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate: Delegator: combine (public|protected) methods withmarcandre2010-05-301-4/+34
| | | | | | | | those of the delegated object. [ruby-core:27224] DelegateClass: combine (public|protected) instance methods with those of the delegated superclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix :nodoc: definition. [ruby-dev:40949]naruse2010-04-101-4/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * object.c (rb_obj_clone): call initialize_clone hook method tomatz2010-02-081-4/+5
| | | | | | | | | | | | | | | | 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
* * lib/delegate.rb (Delegator#method_missing),nobu2010-02-061-16/+8
| | | | | | | | (Delegator.delegating_block): don't hide backtrace from __getobj__ and reduced exception messages when $DEBUG. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator): include copy of Kernel.nobu2010-02-051-11/+15
| | | | | | | | | | [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
* * lib/delegate.rb (Delegator): now inherits BasicObject.nobu2010-02-031-16/+15
| | | | | | | [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
* * lib/delegate.rb (Delegator#marshal_dump): excludenobu2010-02-021-2/+2
| | | | | | | delegator-specific instance variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#initialize_copy): use initialize_copymatz2010-01-281-11/+3
| | | | | | | instead of overriding clone/dup. [ruby-dev:40221] it now always clones the target, it might cause incompatibility. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (marshal_dump/load): Provide forward compatibility ↵marcandre2009-12-291-4/+9
| | | | | | [ruby-core:24211] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (marshal_dump/load): dump & load instance variables by ↵marcandre2009-12-241-1/+7
| | | | | | default [ruby-core:24211] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * object.c (rb_obj_cmp): defines Object#<=>. [ruby-core:24063]matz2009-10-241-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * vm_method.c (basic_obj_respond_to): call #respond_to_missing?matz2009-10-171-1/+1
| | | | | | always with two arguments. [ruby-core:26090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#respond_to_missing): warn only whenmatz2009-10-171-3/+5
| | | | | | specified method is a private. [ruby-dev:39498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate: rdoc typomarcandre2009-10-161-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#method_missing): remove backtracematz2009-10-161-1/+3
| | | | | | lines _until_ `method_missing'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#freeze): #freeze should freeze selfmatz2009-10-161-0/+6
| | | | | | and the target at once. [ruby-core:26118] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator#respond_to_missing): warn if optionalmatz2009-10-161-3/+5
| | | | | | | | | | include_private argument is not false. Delegator does (and should) not forward private methods. [ruby-core:26080] * lib/delegate.rb (Delegator#respond_to_missing): instead of redefining #respond_to?, use #respond_to_missing?. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator::public_api): take snapshot ofmatz2009-10-061-1/+17
| | | | | | | | | | | | 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
* * lib/delegate.rb (Delegator#method_missing): __FILE__ may containmatz2009-08-131-1/+1
| | | | | | multi-byte characters. a patch from Kenta Murata in [ruby-dev:39066]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * {ext,lib,test}/**/*.rb: removed trailing spaces.nobu2009-03-061-18/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator.delegating_block): should not refermatz2008-11-101-1/+1
| | | | | | | DelegateClass specific @delegate_dc_obj. a patch from Erik Hollensbe in [ruby-core:19671]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (DelegateClass): restored 1.8 behavior formatz2008-10-151-78/+70
| | | | | | DelegateClass as well. [ruby-dev:36739] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator): simplified and restored 1.8matz2008-10-141-13/+1
| | | | | | behavior. [ruby-dev:35986] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/rdoc.rb: massive spelling correction patch from Evan Farrarmatz2008-06-041-1/+1
| | | | | | <evanfarrar at gmail.com> in [ruby-doc:1382] applied. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/delegate.rb (Delegator::MethodDelegation#respond_to):knu2008-06-021-2/+2
| | | | | | | | respond_to? should now take optional second argument; submitted by Jeremy Kemper <jeremy at bitsweat.net> in [ruby-core:17045]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e