Class: Corzinus::AddOrderItem
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Corzinus::AddOrderItem
- Defined in:
- app/commands/corzinus/add_order_item.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(order, params) ⇒ AddOrderItem
constructor
A new instance of AddOrderItem.
Constructor Details
#initialize(order, params) ⇒ AddOrderItem
Returns a new instance of AddOrderItem.
5 6 7 8 9 |
# File 'app/commands/corzinus/add_order_item.rb', line 5 def initialize(order, params) @order = order @params = params @quantity = params[:quantity].to_i end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
3 4 5 |
# File 'app/commands/corzinus/add_order_item.rb', line 3 def order @order end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'app/commands/corzinus/add_order_item.rb', line 3 def params @params end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
3 4 5 |
# File 'app/commands/corzinus/add_order_item.rb', line 3 def quantity @quantity end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/commands/corzinus/add_order_item.rb', line 11 def call if added_item.valid? && order.save broadcast :valid, quantity else broadcast :invalid, item_errors end end |