class ActiveForce::Mapping

Public Class Methods

new(model) click to toggle source
# File lib/active_force/mapping.rb, line 11
def initialize model
  @model = model
end

Public Instance Methods

field(name, options) click to toggle source
# File lib/active_force/mapping.rb, line 23
def field name, options
  fields.merge!({ name => ActiveForce::Field.new(name, options) })
end
mappings() click to toggle source
# File lib/active_force/mapping.rb, line 15
def mappings
  @mappings ||= Hash[fields.map { |field, attr| [field, attr.sfdc_name] }]
end
sfdc_names() click to toggle source
# File lib/active_force/mapping.rb, line 19
def sfdc_names
  mappings.values
end
table() click to toggle source
# File lib/active_force/mapping.rb, line 27
def table
  @table ||= ActiveForce::Table.new @model
end
translate_to_sf(attributes) click to toggle source
# File lib/active_force/mapping.rb, line 31
def translate_to_sf attributes
  attrs = attributes.map do |attribute, value|
    field = fields[attribute.to_sym]
    [field.sfdc_name, field.value_for_hash(value)]
  end
  Hash[attrs]
end
translate_value(value, field_name) click to toggle source
# File lib/active_force/mapping.rb, line 39
def translate_value value, field_name
  return value unless !!field_name
  value
end

Private Instance Methods

fields() click to toggle source
# File lib/active_force/mapping.rb, line 47
def fields
  @fields ||= {}
end