5

Possible Duplicate:
Calling a Function From a String With the Function's Name in Ruby

I want to do something like this:

  def self.greater_than(col_str='events')
    self."#{col_str}"_greater_than(30) # search logic scope method
  end

How can I get this to call properly? I'm guessing the syntax is probably similar to creating a dynamic method.

0

2 Answers 2

13

You could try using send

send("#{col_str}_greater_than".to_sym, 30)
0

Try this

def self.greater_than(col_str='events')
  self.send("#{col_str}_greater_than", 30) # search logic scope method
end

Not the answer you're looking for? Browse other questions tagged or ask your own question.