Class: Address
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Address
- Defined in:
- app/models/address.rb
Instance Method Summary collapse
- #country_name ⇒ Object
- #filled_in? ⇒ Boolean
- #name ⇒ Object
- #order ⇒ Object
- #parts ⇒ Object
- #readable_parts ⇒ Object
- #shipping_rules ⇒ Object
Instance Method Details
#country_name ⇒ Object
9 10 11 |
# File 'app/models/address.rb', line 9 def country_name Carmen::country_name(country) end |
#filled_in? ⇒ Boolean
21 22 23 |
# File 'app/models/address.rb', line 21 def filled_in? address? && country? end |
#name ⇒ Object
25 26 27 28 29 30 |
# File 'app/models/address.rb', line 25 def name [].tap do |out| out << firstname if firstname.present? out << lastname if lastname.present? end.join(' ') end |
#order ⇒ Object
13 14 15 |
# File 'app/models/address.rb', line 13 def order order_as_shipping.present? ? order_as_shipping : order_as_billing end |
#parts ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/address.rb', line 32 def parts [].tap do |out| out << name if address.present? address.split("\n").each do |line| out << line end end out << city if city.present? out << state_province_region if state_province_region.present? out << zip_postal_code if zip_postal_code.present? out << country_name if country.present? end end |
#readable_parts ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/models/address.rb', line 47 def readable_parts [].tap do |out| out << name if address.present? address.split("\n").each do |line| out << line end end last_line = [] last_line << city if city.present? last_line << state_province_region if state_province_region.present? last_line << zip_postal_code if zip_postal_code.present? out << last_line.join(', ') out << country_name if country.present? end end |
#shipping_rules ⇒ Object
17 18 19 |
# File 'app/models/address.rb', line 17 def shipping_rules ShippingRule.for_country(country) end |