summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-method/mrblib
diff options
context:
space:
mode:
authorksss <[email protected]>2017-12-18 10:54:37 +0900
committerksss <[email protected]>2017-12-18 10:54:37 +0900
commitb83ff8ccd8294de76bf8dbdea27ace70a667688a (patch)
treee9712c35c21256b927761c28ae42ae14508d1ae1 /mrbgems/mruby-method/mrblib
parentddb1aae41de507efb9ab3d7ec2edb23911888783 (diff)
downloadmruby-b83ff8ccd8294de76bf8dbdea27ace70a667688a.tar.gz
mruby-b83ff8ccd8294de76bf8dbdea27ace70a667688a.zip
Add mrbgems/mruby-method
from https://github.com/ksss/mruby-method/commit/0837a0b507a5b4cdf8a1f1039ee371cee4e3b7fb
Diffstat (limited to 'mrbgems/mruby-method/mrblib')
-rw-r--r--mrbgems/mruby-method/mrblib/kernel.rb9
-rw-r--r--mrbgems/mruby-method/mrblib/method.rb20
-rw-r--r--mrbgems/mruby-method/mrblib/unbound_method.rb9
3 files changed, 38 insertions, 0 deletions
diff --git a/mrbgems/mruby-method/mrblib/kernel.rb b/mrbgems/mruby-method/mrblib/kernel.rb
new file mode 100644
index 000000000..b2ebd45ea
--- /dev/null
+++ b/mrbgems/mruby-method/mrblib/kernel.rb
@@ -0,0 +1,9 @@
+module Kernel
+ def singleton_method(name)
+ m = method(name)
+ if m.owner != singleton_class
+ raise NameError, "undefined method `#{name}' for class `#{singleton_class}'"
+ end
+ m
+ end
+end
diff --git a/mrbgems/mruby-method/mrblib/method.rb b/mrbgems/mruby-method/mrblib/method.rb
new file mode 100644
index 000000000..5de0afdf7
--- /dev/null
+++ b/mrbgems/mruby-method/mrblib/method.rb
@@ -0,0 +1,20 @@
+class Method
+ def to_proc
+ m = self
+ lambda { |*args, &b|
+ m.call(*args, &b)
+ }
+ end
+
+ def owner
+ @owner
+ end
+
+ def receiver
+ @recv
+ end
+
+ def name
+ @name
+ end
+end
diff --git a/mrbgems/mruby-method/mrblib/unbound_method.rb b/mrbgems/mruby-method/mrblib/unbound_method.rb
new file mode 100644
index 000000000..1d3acf3fa
--- /dev/null
+++ b/mrbgems/mruby-method/mrblib/unbound_method.rb
@@ -0,0 +1,9 @@
+class UnboundMethod
+ def owner
+ @owner
+ end
+
+ def name
+ @name
+ end
+end