class Kameleon::DSL::Act::Form

Attributes

actions[R]
params[R]

Public Class Methods

new(params) click to toggle source
# File lib/kameleon/dsl/act/form.rb, line 8
def initialize(params)
  raise "not supported" unless params.kind_of?(Hash)
  @params = params
  @actions = []
  parse_actions
end

Private Instance Methods

parse_actions() click to toggle source
# File lib/kameleon/dsl/act/form.rb, line 17
def parse_actions
  prepare_actions(params)
end
prepare_actions(param) click to toggle source
# File lib/kameleon/dsl/act/form.rb, line 21
def prepare_actions(param)
  param.each_pair do |value, identifier|
    case identifier
      when Array
        identifier.each { |identifier| prepare_actions(value => identifier) }
      when Symbol
        prepare_actions(value => identifier.to_s)
      else
        case value
          when Fixnum, Float, String
            actions << Action.new(:fill_in, identifier, :with => value)
          when :check, :choose, :uncheck
            actions << Action.new(value, identifier)
          when :select, :unselect
            actions.concat SelectTag.new(value, identifier).actions
          when :attach
            actions.concat AttachFileTag.new(identifier).actions
          else
            raise "not implemented"
        end
    end
  end
end