Class: Checkout::StreetAddress
- Inherits:
-
Object
- Object
- Checkout::StreetAddress
- Includes:
- ActiveModel::API, ActiveModel::Attributes, ActiveModel::Validations, ActiveModel::Validations::Callbacks, StripAttributes
- Defined in:
- app/forms/checkout/street_address.rb
Overview
Form object: street address.
Instance Method Summary collapse
- #address_complete? ⇒ Boolean
-
#address_type_options ⇒ Object
Bare mininum information we need for a valid address.
- #full_address(include_recipient = true, sep = '.', _attn_override = nil, _hide_country = false, hide_street_2 = false) ⇒ Object
Instance Method Details
#address_complete? ⇒ Boolean
37 38 39 |
# File 'app/forms/checkout/street_address.rb', line 37 def address_complete? %i[street1 city state_code postal_code country_iso3].all? { |f| send(f).presence } end |
#address_type_options ⇒ Object
Bare mininum information we need for a valid address
30 31 32 33 34 35 |
# File 'app/forms/checkout/street_address.rb', line 30 def [['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
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/forms/checkout/street_address.rb', line 41 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 if recipient.present? end addr << street1.to_s.strip if street1.present? addr << street2.to_s.strip unless street2.blank? || hide_street_2 addr << "#{city.to_s.strip}, #{state_code} #{postal_code.to_s.strip}" addr = addr.uniq.compact addr.join(sep) end |