Module: Shippinglogic::FedEx::Attributes::InstanceMethods

Defined in:
lib/shippinglogic/fedex/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject

Returns a hash of the various attribute values

[View source]

48
49
50
51
52
53
54
# File 'lib/shippinglogic/fedex/attributes.rb', line 48

def attributes
  attributes = {}
  attribute_names.each do |name|
    attributes[name] = send(name)
  end
  attributes
end

#attributes=(value) ⇒ Object

Accepts a hash of attribute values and sets each attribute to those values

[View source]

57
58
59
60
61
62
63
# File 'lib/shippinglogic/fedex/attributes.rb', line 57

def attributes=(value)
  return if value.blank?
  value.each do |key, value|
    next if !attribute_names.include?(key.to_sym)
    send("#{key}=", value)
  end
end

#initialize(base, attributes = {}) ⇒ Object

A convenience so that you can set attributes while initializing an object

[View source]

42
43
44
45
# File 'lib/shippinglogic/fedex/attributes.rb', line 42

def initialize(base, attributes = {})
  @attributes = {}
  self.attributes = attributes
end