Class: Corzinus::AddOrderItem

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/corzinus/add_order_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#orderObject (readonly)

Returns the value of attribute order.



3
4
5
# File 'app/commands/corzinus/add_order_item.rb', line 3

def order
  @order
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/commands/corzinus/add_order_item.rb', line 3

def params
  @params
end

#quantityObject (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

#callObject



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