Module: Spree::Order::AddressBook
- Extended by:
- ActiveSupport::Concern
- Included in:
- Spree::Order
- Defined in:
- app/models/spree/order/address_book.rb
Instance Method Summary collapse
- #bill_address_attributes=(attributes) ⇒ Object
- #bill_address_id=(id) ⇒ Object
- #clone_billing_address ⇒ Object
- #clone_shipping_address ⇒ Object
- #ship_address_attributes=(attributes) ⇒ Object
- #ship_address_id=(id) ⇒ Object
Instance Method Details
#bill_address_attributes=(attributes) ⇒ Object
31 32 33 34 |
# File 'app/models/spree/order/address_book.rb', line 31 def bill_address_attributes=(attributes) self.bill_address = update_or_create_address(attributes) user.bill_address = bill_address if user && user.bill_address.nil? end |
#bill_address_id=(id) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/models/spree/order/address_book.rb', line 21 def bill_address_id=(id) address = Spree::Address.find_by(id: id) if address && address.user_id == user_id self['bill_address_id'] = address.id bill_address.reload else self['bill_address_id'] = nil end end |
#clone_billing_address ⇒ Object
14 15 16 17 18 19 |
# File 'app/models/spree/order/address_book.rb', line 14 def clone_billing_address if bill_address self.ship_address = bill_address end true end |
#clone_shipping_address ⇒ Object
7 8 9 10 11 12 |
# File 'app/models/spree/order/address_book.rb', line 7 def clone_shipping_address if ship_address self.bill_address = ship_address end true end |
#ship_address_attributes=(attributes) ⇒ Object
46 47 48 49 |
# File 'app/models/spree/order/address_book.rb', line 46 def ship_address_attributes=(attributes) self.ship_address = update_or_create_address(attributes) user.ship_address = ship_address if user && user.ship_address.nil? end |
#ship_address_id=(id) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/models/spree/order/address_book.rb', line 36 def ship_address_id=(id) address = Spree::Address.find_by(id: id) if address && address.user_id == user_id self['ship_address_id'] = address.id ship_address.reload else self['ship_address_id'] = nil end end |