0

Using workflow is amazing! it defines states and new methods as "can_submit?" and so "submit!"

there is a way to verify an action and so execute it?

def do(name)
    canDoIt = eval "self.can_" + name + "?" 
    canDoIt ? eval "self." + name + "!" : "Sorry...cant do that action..."
end

how could be done? thanks!

Bonzo
  • 427
  • 2
  • 10
  • 28

1 Answers1

0

Not sure I understand the question...
Is this what you want?

def do(name)
  if respond_to?("#{name}!") && send("can_#{name}?")
    send("#{name}!")
  else
    'Sorry...cant do that action...'
  end
end
user3033467
  • 1,078
  • 15
  • 24