Class: Address

Inherits:
ActiveRecord::Base show all
Defined in:
app/models/address.rb

Direct Known Subclasses

BillingAddress, ShippingAddress

Constant Summary collapse

CREDIT_CARD_ATTRIBUTES =
%w(address1 address2 zipcode first_name last_name)

Instance Method Summary collapse

Instance Method Details

#address_lines(join_chars = ', ') ⇒ Object



19
20
21
# File 'app/models/address.rb', line 19

def address_lines(join_chars = ', ')
  [address1, address2].delete_if { |add| add.blank? }.join(join_chars)
end

#city_state_nameObject



23
24
25
# File 'app/models/address.rb', line 23

def city_state_name
  [city, state_name].join(', ')
end

#city_state_zipObject



27
28
29
# File 'app/models/address.rb', line 27

def city_state_zip
  [city_state_name, zipcode].join(' ')
end

#full_address_arrayObject



11
12
13
# File 'app/models/address.rb', line 11

def full_address_array
  [name, address1, address2, city_state_zip, country_name].compact
end

#nameObject



15
16
17
# File 'app/models/address.rb', line 15

def name
  [first_name, last_name].compact.join(' ')
end

#to_credit_card_attributesObject



31
32
33
# File 'app/models/address.rb', line 31

def to_credit_card_attributes
  attributes.slice(*CREDIT_CARD_ATTRIBUTES).merge('state' => state_name)
end