Skip to content

Instantly share code, notes, and snippets.

@no6v
Created February 28, 2013 13:11
Show Gist options
  • Save no6v/5056612 to your computer and use it in GitHub Desktop.
Save no6v/5056612 to your computer and use it in GitHub Desktop.
RUBY_DESCRIPTION # => "ruby 2.1.0dev (2013-02-28 trunk 39535) [x86_64-linux]"
module PM
def m(a, b)
end
end
class PC
prepend PM
def m(a)
end
end
pm = PC.instance_method(:m)
pm.owner # => #<PC:0x000000015c1420>
pm.parameters # => [[:req, :a]]
PC.new.m(:a, :b) # => nil
class RC
def m(a)
end
end
module RM
refine RC do # !> Refinements are experimental, and the behavior may change in future versions of Ruby!
def m(a, b)
end
end
end
using RM
rm = RC.instance_method(:m)
rm.owner # => RC
rm.parameters # => [[:req, :a]]
RC.new.m(:a, :b) # => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment