Class: Method

Inherits:
Object show all
Defined in:
lib/backports/1.8.7/method/name.rb,
lib/backports/1.9.1/proc/lambda.rb,
lib/backports/2.2.0/method/curry.rb,
lib/backports/2.6.0/method/compose.rb,
lib/backports/2.2.0/method/super_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/backports/1.8.7/method/name.rb', line 5

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'lib/backports/1.8.7/method/name.rb', line 5

def owner
  @owner
end

#receiverObject

Returns the value of attribute receiver.



5
6
7
# File 'lib/backports/1.8.7/method/name.rb', line 5

def receiver
  @receiver
end

Instance Method Details

#<<(g) ⇒ Object



5
6
7
# File 'lib/backports/2.6.0/method/compose.rb', line 5

def <<(g)
  to_proc << g
end

#>>(g) ⇒ Object



9
10
11
# File 'lib/backports/2.6.0/method/compose.rb', line 9

def >>(g)
  to_proc >> g
end

#curry(argc = nil) ⇒ Object



5
6
7
# File 'lib/backports/2.2.0/method/curry.rb', line 5

def curry(argc = nil)
  to_proc.curry(argc)
end

#super_methodObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/backports/2.2.0/method/super_method.rb', line 5

def super_method
  singleton_klass = class << receiver; self; end
  call_chain = singleton_klass.ancestors
  # find current position in call chain:
  skip = call_chain.find_index {|c| c == owner} or return
  call_chain = call_chain.drop(skip + 1)
  # find next in chain with a definition:
  next_index = call_chain.find_index {|c| c.method_defined? name}
  next_index && call_chain[next_index].instance_method(name).bind(receiver)
end

#to_proc_with_lambda_trackingObject



16
17
18
19
20
# File 'lib/backports/1.9.1/proc/lambda.rb', line 16

def to_proc_with_lambda_tracking
  proc = to_proc_without_lambda_tracking
  proc.send :__is_lambda__=, true
  proc
end

#unbind_with_additional_infoObject



7
8
9
10
11
12
# File 'lib/backports/1.8.7/method/name.rb', line 7

def unbind_with_additional_info
  unbound = unbind_without_additional_info
  unbound.name = name
  unbound.owner = owner
  unbound
end