module CardConnect::Utils

Public Instance Methods

set_attributes(attributes, fields) click to toggle source
# File lib/cardconnect/utils.rb, line 3
def set_attributes(attributes, fields)
  return if attributes.empty?
  attributes = attributes[0] if attributes.is_a? Array
  attributes = symbolize_keys(attributes)

  fields.each do |attr|
    next if attributes[attr].nil?
    send("#{attr}=", attributes[attr])
  end
end
symbolize_keys(hash) click to toggle source
# File lib/cardconnect/utils.rb, line 14
def symbolize_keys(hash)
  hash.collect{|key, value| {key.to_sym => value} }.reduce({}, :merge)
end