diff options
Diffstat (limited to 'mrbgems/mruby-method/mrblib')
| -rw-r--r-- | mrbgems/mruby-method/mrblib/kernel.rb | 9 | ||||
| -rw-r--r-- | mrbgems/mruby-method/mrblib/method.rb | 20 | ||||
| -rw-r--r-- | mrbgems/mruby-method/mrblib/unbound_method.rb | 9 |
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 |
