This is what I finally ended up with - which I think is quite elegant
:)
class Foo
def bar(quantal, *args, &block)
if block_given?
lambd = lambda(&block)
class << lambd
@@return = {}.extend(Appenders::Hashs)
def method_missing(m, *args, &block)
return @@return << { m.to_sym => args_to_attributes(args) }
end
end
attributes = lambd.instance_eval(&lambd)
end
parse quantal, attributes
end
end # Foo
What made this sweet for me was turning the &block into a lambda let me
return the result from the instance_eval to bar where other solutions
kept them in scope of the &block.
James