Class: SpreeCmCommissioner::IntercityTaxiOrder::Update

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/intercity_taxi_order/update.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order_number:, params:) ⇒ Update

Returns a new instance of Update.



10
11
12
13
# File 'app/services/spree_cm_commissioner/intercity_taxi_order/update.rb', line 10

def initialize(order_number:, params:)
  @order_number = order_number
  @params = ensure_parameters(params)
end

Instance Attribute Details

#order_numberObject (readonly)

Returns the value of attribute order_number.



4
5
6
# File 'app/services/spree_cm_commissioner/intercity_taxi_order/update.rb', line 4

def order_number
  @order_number
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'app/services/spree_cm_commissioner/intercity_taxi_order/update.rb', line 4

def params
  @params
end

Class Method Details

.call(order_number:, params:) ⇒ Object



6
7
8
# File 'app/services/spree_cm_commissioner/intercity_taxi_order/update.rb', line 6

def self.call(order_number:, params:)
  new(order_number: order_number, params: params).call
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
# File 'app/services/spree_cm_commissioner/intercity_taxi_order/update.rb', line 15

def call
  order = Spree::Order.find_by!(number: order_number)
  order.update!(order_params)

  create_billing_address_if_missing(order)

  order
end