Sha256: 4dac83dcf8a0b0d859be5809981922d21af2a35857bc06359c7c87e0380edd23

Contents?: true

Size: 644 Bytes

Versions: 13

Compression:

Stored size: 644 Bytes

Contents

module ActiveForce
  class Field

    attr_accessor :local_name, :sfdc_name, :as

    def initialize name, options = {}
      self.local_name = name
      self.sfdc_name  = options[:sfdc_name] || options[:from] || default_api_name
      self.as         = options[:as]        || :string
    end

    def value_for_hash value
      case as
      when :datetime
        value&.to_fs(:iso8601)
      else
        value
      end
    end

    private

    ###
    # Transforms +attribute+ to the conventional Salesforce API name.
    #
    def default_api_name
      local_name.to_s.split('_').map(&:capitalize).join('_') << '__c'
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
active_force-0.24.0 lib/active_force/field.rb
active_force-0.23.0 lib/active_force/field.rb
active_force-0.22.1 lib/active_force/field.rb
active_force-0.22.0 lib/active_force/field.rb
active_force-0.21.0 lib/active_force/field.rb
active_force-0.20.1 lib/active_force/field.rb
active_force-0.20.0 lib/active_force/field.rb
active_force-0.19.0 lib/active_force/field.rb
active_force-0.18.0 lib/active_force/field.rb
active_force-0.17.0 lib/active_force/field.rb
active_force-0.16.0 lib/active_force/field.rb
active_force-0.15.1 lib/active_force/field.rb
active_force-0.15.0 lib/active_force/field.rb