module Formotion::RowType

Constants

ROW_TYPES

Public Class Methods

for(string_or_sym) click to toggle source
# File lib/formotion/row_type/row_type.rb, line 6
def for(string_or_sym)
  type = string_or_sym

  if type.is_a?(Symbol) or type.is_a? String
    string = "#{type.to_s.downcase}_row".camelize
    if not const_defined? string
      raise Formotion::InvalidClassError, "Invalid RowType value #{string_or_sym}. Create a class called #{string}"
    end
    Formotion::RowType.const_get(string)
  else
    raise Formotion::InvalidClassError, "Attempted row type #{type.inspect} is not a valid RowType."
  end
end