How do I pass a conditional expression as a parameter in Ruby?

Posted by srayhan on Stack Overflow See other posts from Stack Overflow or by srayhan
Published on 2010-06-10T19:06:24Z Indexed on 2010/06/10 19:12 UTC
Read the original article Hit count: 109

Filed under:

For example this what I am trying to do,

def method_a(condition, params={}, &block)
   if condition
      method_b(params, &block)
   else
      yield
   end
end

and I am trying to call the method like this,

method_a(#{@date > Date.today}, {:param1 => 'value1', :param2 => 'value2'}) do

end

The result is the condition is always evaluated to true. How do I make it work?

© Stack Overflow or respective owner

Related posts about ruby