/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# encoding: utf-8 class Parent attr_reader :one, :two end class FirstChild < Parent def initialize @one = 'first one' @two = 'first two' end end class SecondChild < Parent def initialize @one = 'second one' @two = 'second two' end end one = Parent.new.method(:one).unbind two = Parent.new.method(:two).unbind puts one.bind(FirstChild.new).call #=> first one puts two.bind(FirstChild.new).call #=> first two puts one.bind(SecondChild.new).call #=> second one puts two.bind(SecondChild.new).call #=> second two
Comments
