Method: CongressForms::Actions.build
- Defined in:
- lib/congress_forms/actions.rb
.build(step) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/congress_forms/actions.rb', line 7 def self.build(step) key = step.keys.first const_name = key.capitalize.gsub(/_(\w)/){ |m| m[1].upcase } begin klass = const_get(const_name, false) rescue NameError => e raise UnsupportedAction, "#{const_name} handler missing" end if Visit == klass Array(klass.new("value" => step[key])) else step[key].map do |params| klass.new(params) end end end |