Class: Piggybak::Address
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Piggybak::Address
- Defined in:
- app/models/piggybak/address.rb
Instance Attribute Summary collapse
-
#is_shipping ⇒ Object
Returns the value of attribute is_shipping.
Instance Method Summary collapse
- #admin_label ⇒ Object (also: #display)
-
#document_address_changes ⇒ Object
TODO: Fix this.
- #set_default_country ⇒ Object
- #state_display ⇒ Object
Instance Attribute Details
#is_shipping ⇒ Object
Returns the value of attribute is_shipping.
19 20 21 |
# File 'app/models/piggybak/address.rb', line 19 def is_shipping @is_shipping end |
Instance Method Details
#admin_label ⇒ Object Also known as: display
25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/piggybak/address.rb', line 25 def admin_label address = "#{self.firstname} #{self.lastname}<br />" address += "#{self.address1}<br />" if self.address2 && self.address2 != '' address += "#{self.address2}<br />" end address += "#{self.city}, #{self.state_display} #{self.zip}<br />" address += "#{self.country.name}" address end |
#document_address_changes ⇒ Object
TODO: Fix this. It isn’t working.
42 43 44 45 46 47 48 49 |
# File 'app/models/piggybak/address.rb', line 42 def document_address_changes if self.order_billing.present? && self.changed? self.order_billing.recorded_changes << self.formatted_changes end if self.order_shipping.present? && self.changed? self.order_shipping.recorded_changes << self.formatted_changes end end |
#set_default_country ⇒ Object
21 22 23 |
# File 'app/models/piggybak/address.rb', line 21 def set_default_country self.country ||= Country.where(abbr: Piggybak.config.default_country).first end |
#state_display ⇒ Object
37 38 39 |
# File 'app/models/piggybak/address.rb', line 37 def state_display self.state ? self.state.name : self.state_id end |