* lib/delegate.rb: Added missing spaces and Removed needless spaces.
[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
This commit is contained in:
parent
69846644d2
commit
22de22b292
@ -1,3 +1,8 @@
|
|||||||
|
Wed Oct 5 11:36:21 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/delegate.rb: Added missing spaces and Removed needless spaces.
|
||||||
|
[fix GH-1454][ci skip] Patch by @bogdanvlviv
|
||||||
|
|
||||||
Wed Oct 5 03:24:55 2016 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
Wed Oct 5 03:24:55 2016 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
* enum.c: Make Enumerable#chunk with no block return
|
* enum.c: Make Enumerable#chunk with no block return
|
||||||
|
@ -40,7 +40,7 @@ class Delegator < BasicObject
|
|||||||
kernel = ::Kernel.dup
|
kernel = ::Kernel.dup
|
||||||
kernel.class_eval do
|
kernel.class_eval do
|
||||||
alias __raise__ raise
|
alias __raise__ raise
|
||||||
[:to_s,:inspect,:=~,:!~,:===,:<=>,:eql?,:hash].each do |m|
|
[:to_s, :inspect, :=~, :!~, :===, :<=>, :eql?, :hash].each do |m|
|
||||||
undef_method m
|
undef_method m
|
||||||
end
|
end
|
||||||
private_instance_methods.each do |m|
|
private_instance_methods.each do |m|
|
||||||
@ -175,7 +175,7 @@ class Delegator < BasicObject
|
|||||||
ivars = instance_variables.reject {|var| /\A@delegate_/ =~ var}
|
ivars = instance_variables.reject {|var| /\A@delegate_/ =~ var}
|
||||||
[
|
[
|
||||||
:__v2__,
|
:__v2__,
|
||||||
ivars, ivars.map{|var| instance_variable_get(var)},
|
ivars, ivars.map {|var| instance_variable_get(var)},
|
||||||
__getobj__
|
__getobj__
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -186,7 +186,7 @@ class Delegator < BasicObject
|
|||||||
def marshal_load(data)
|
def marshal_load(data)
|
||||||
version, vars, values, obj = data
|
version, vars, values, obj = data
|
||||||
if version == :__v2__
|
if version == :__v2__
|
||||||
vars.each_with_index{|var, i| instance_variable_set(var, values[i])}
|
vars.each_with_index {|var, i| instance_variable_set(var, values[i])}
|
||||||
__setobj__(obj)
|
__setobj__(obj)
|
||||||
else
|
else
|
||||||
__setobj__(data)
|
__setobj__(data)
|
||||||
@ -234,7 +234,7 @@ class Delegator < BasicObject
|
|||||||
end
|
end
|
||||||
|
|
||||||
@delegator_api = self.public_instance_methods
|
@delegator_api = self.public_instance_methods
|
||||||
def self.public_api # :nodoc:
|
def self.public_api # :nodoc:
|
||||||
@delegator_api
|
@delegator_api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -305,7 +305,7 @@ end
|
|||||||
# Non-Nil: 7
|
# Non-Nil: 7
|
||||||
# Unique: 6
|
# Unique: 6
|
||||||
#
|
#
|
||||||
class SimpleDelegator<Delegator
|
class SimpleDelegator < Delegator
|
||||||
# Returns the current object method calls are being delegated to.
|
# Returns the current object method calls are being delegated to.
|
||||||
def __getobj__
|
def __getobj__
|
||||||
unless defined?(@delegate_sd_obj)
|
unless defined?(@delegate_sd_obj)
|
||||||
@ -379,9 +379,9 @@ def DelegateClass(superclass)
|
|||||||
klass = Class.new(Delegator)
|
klass = Class.new(Delegator)
|
||||||
methods = superclass.instance_methods
|
methods = superclass.instance_methods
|
||||||
methods -= ::Delegator.public_api
|
methods -= ::Delegator.public_api
|
||||||
methods -= [:to_s,:inspect,:=~,:!~,:===]
|
methods -= [:to_s, :inspect, :=~, :!~, :===]
|
||||||
klass.module_eval do
|
klass.module_eval do
|
||||||
def __getobj__ # :nodoc:
|
def __getobj__ # :nodoc:
|
||||||
unless defined?(@delegate_dc_obj)
|
unless defined?(@delegate_dc_obj)
|
||||||
return yield if block_given?
|
return yield if block_given?
|
||||||
__raise__ ::ArgumentError, "not delegated"
|
__raise__ ::ArgumentError, "not delegated"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user