Class: Corzinus::UpdateOrder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, params) ⇒ UpdateOrder

Returns a new instance of UpdateOrder.



5
6
7
8
# File 'app/commands/corzinus/update_order.rb', line 5

def initialize(order, params)
  @order = order
  @params = params
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



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

def order
  @order
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
# File 'app/commands/corzinus/update_order.rb', line 10

def call
  if coupon_valid? && update_order
    type = params[:to_checkout] ? :to_checkout : :valid
    broadcast type
  else
    broadcast :invalid, coupon_form
  end
end