Rubyで遅延メソッド実行を実装しようとしています。呼び出しの直後に実行されるべきではない2つのメソッドを持つクラスがあるとしましょう
class Foo
lazy_evaluate :bar, :baz
def bar(string)
puts string
end
def baz(hash)
puts hash.inspect
end
end
f = Foo.new
f.bar('hello world') => nil
f.baz(hello: :world) => nil
f.run_lazy_methods =>
'hello world'
'{:hello=>:world}'
私は私の宝石でこれを使用したくないhttp://pastie.org/5137463
この動作を実装する方法のアイデアを求めています