Class: Checkout::StreetAddress

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::API, ActiveModel::Attributes, ActiveModel::Validations, ActiveModel::Validations::Callbacks, StripAttributes
Defined in:
app/forms/checkout/street_address.rb

Instance Method Summary collapse

Instance Method Details

#address_complete?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/forms/checkout/street_address.rb', line 34

def address_complete?
  %i( street1 city state_code postal_code country_iso3 ).all?{|f| send(f).presence }
end

#address_type_optionsObject

Bare mininum information we need for a valid address



27
28
29
30
31
32
# File 'app/forms/checkout/street_address.rb', line 27

def address_type_options
  [ ['Residential', 'residential'],
    ['Commercial Building with Receiving Dock', 'commercial_building_with_receiving_dock'],
    ['Commercial Building without Receiving Dock', 'commercial_building_without_receiving_dock'],
    ['Construction Site/Limited Access', 'construction_site']]
end

#full_address(include_recipient = true, sep = '.', attn_override = nil, hide_country = false, hide_street_2 = false) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'app/forms/checkout/street_address.rb', line 38

def full_address(include_recipient=true, sep = '.', attn_override = nil, hide_country = false, hide_street_2 = false)
  addr = []
  if include_recipient
    addr << recipient.to_s.strip unless recipient.blank?
  end
  addr << street1.to_s.strip unless street1.blank?
  addr << street2.to_s.strip unless street2.blank? or hide_street_2
  addr << "#{city.to_s.strip}, #{state_code} #{postal_code.to_s.strip}"
  addr = addr.uniq.compact
  return addr.join(sep)
end