Class: Workarea::Checkout::AutoComplete
- Inherits:
-
Object
- Object
- Workarea::Checkout::AutoComplete
- Defined in:
- app/models/workarea/checkout/auto_complete.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#billing_address ⇒ Address?
The billing address used to autocomplete the checkout.
-
#credit_card ⇒ Payment::SavedCreditCard?
The credit card used to autocomplete the checkout.
-
#initialize(order, payment, user) ⇒ AutoComplete
constructor
A new instance of AutoComplete.
-
#params ⇒ Hash
The params for the most autocomplete info that is present for the current user.
-
#shipping_address ⇒ Address?
The shipping address used to autocomplete the checkout.
Constructor Details
#initialize(order, payment, user) ⇒ AutoComplete
Returns a new instance of AutoComplete.
10 11 12 13 14 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 10 def initialize(order, payment, user) @order = order @payment = payment @user = user end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
8 9 10 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 8 def order @order end |
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
8 9 10 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 8 def payment @payment end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 8 def user @user end |
Instance Method Details
#billing_address ⇒ Address?
The billing address used to autocomplete the checkout.
47 48 49 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 47 def billing_address user.default_billing_address end |
#credit_card ⇒ Payment::SavedCreditCard?
The credit card used to autocomplete the checkout.
64 65 66 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 64 def credit_card payment.default_credit_card end |
#params ⇒ Hash
The params for the most autocomplete info that is present for the current user. Passed to Workarea::Checkout#update to autocomplete the order.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 22 def params result = { email: user.email, payment: credit_card.try(:id) } if billing_address.present? result[:billing_address] = billing_address.attributes.slice( *address_attr_keys ) end if shipping_address.present? result[:shipping_address] = shipping_address.attributes.slice( *address_attr_keys ) end result end |
#shipping_address ⇒ Address?
The shipping address used to autocomplete the checkout.
56 57 58 |
# File 'app/models/workarea/checkout/auto_complete.rb', line 56 def shipping_address user.default_shipping_address end |