Class: PowerShop::OrderForm
- Inherits:
-
Object
- Object
- PowerShop::OrderForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/forms/power_shop/order_form.rb
Overview
class represent form for create new order TODO: this class want specs
Instance Attribute Summary collapse
-
#cart ⇒ Object
readonly
Returns the value of attribute cart.
-
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#user_email ⇒ Object
Returns the value of attribute user_email.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
-
#user_phone ⇒ Object
Returns the value of attribute user_phone.
Instance Method Summary collapse
-
#initialize(cart, attributes = {}) ⇒ OrderForm
constructor
Public: initialize new order form.
-
#perform ⇒ Object
Public: process create new order, clear cart, and sent notifications.
Constructor Details
Instance Attribute Details
#cart ⇒ Object (readonly)
Returns the value of attribute cart.
10 11 12 |
# File 'app/forms/power_shop/order_form.rb', line 10 def cart @cart end |
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
9 10 11 |
# File 'app/forms/power_shop/order_form.rb', line 9 def delivery_address @delivery_address end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
10 11 12 |
# File 'app/forms/power_shop/order_form.rb', line 10 def order @order end |
#user_email ⇒ Object
Returns the value of attribute user_email.
9 10 11 |
# File 'app/forms/power_shop/order_form.rb', line 9 def user_email @user_email end |
#user_name ⇒ Object
Returns the value of attribute user_name.
9 10 11 |
# File 'app/forms/power_shop/order_form.rb', line 9 def user_name @user_name end |
#user_phone ⇒ Object
Returns the value of attribute user_phone.
9 10 11 |
# File 'app/forms/power_shop/order_form.rb', line 9 def user_phone @user_phone end |
Instance Method Details
#perform ⇒ Object
Public: process create new order, clear cart, and sent notifications
Example:
if @order_form.valid?
@order_form.perform
Returns boolean
34 35 36 37 38 39 40 41 42 43 |
# File 'app/forms/power_shop/order_form.rb', line 34 def perform return false unless valid? if result = make_order cart.clear send_emails end result end |