first commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
module Kernel
|
||||
def singleton_method(name)
|
||||
m = method(name)
|
||||
sc = (class <<self; self; end)
|
||||
if m.owner != sc
|
||||
raise NameError, "undefined method '#{name}' for class '#{sc}'"
|
||||
end
|
||||
m
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
class Method
|
||||
def to_proc
|
||||
m = self
|
||||
lambda { |*args, &b|
|
||||
m.call(*args, &b)
|
||||
}
|
||||
end
|
||||
|
||||
def <<(other)
|
||||
->(*args, &block) { call(other.call(*args, &block)) }
|
||||
end
|
||||
|
||||
def >>(other)
|
||||
->(*args, &block) { other.call(call(*args, &block)) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user