Method: Sequent::Core::Helpers::ParamSupport#as_params

Defined in:
lib/sequent/core/helpers/param_support.rb

#as_paramsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/sequent/core/helpers/param_support.rb', line 58

def as_params
  hash = HashWithIndifferentAccess.new
  self.class.types.each do |field|
    value = self.instance_variable_get("@#{field[0]}")
    next if field[0] == "errors"
    hash[field[0]] = if value.kind_of?(Array)
                       next if value.blank?
                       value.map { |v| value_to_string(v) }
                     else
                       value_to_string(value)
                     end
  end
  hash
end