Essentially I\'m wondering if the following can be done in Ruby.
So for example:
def bar(symbol) # magic code goes here, it outputs \"a = 100\"
Here's a easier syntax hack, using a passed in block binding:
def loginfo &block what = yield.to_s evaled = eval(what, block.binding) Rails.logger.info "#{what} = #{evaled.inspect}" end
called like this:
x = 1 loginfo{ :x }
will log out:
x = 1