Class: SpreeCmCommissioner::Routes::BaseUpdateOrderMetrics
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Routes::BaseUpdateOrderMetrics
- Defined in:
- app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb
Constant Summary collapse
- SUPPORTED_ATTRIBUTES =
i[order_count fulfilled_order_count].freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(order:, attribute:) ⇒ BaseUpdateOrderMetrics
constructor
A new instance of BaseUpdateOrderMetrics.
Constructor Details
#initialize(order:, attribute:) ⇒ BaseUpdateOrderMetrics
Returns a new instance of BaseUpdateOrderMetrics.
8 9 10 11 |
# File 'app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb', line 8 def initialize(order:, attribute:) @order = order @attribute = attribute&.to_sym end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
4 5 6 |
# File 'app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb', line 4 def attribute @attribute end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
4 5 6 |
# File 'app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb', line 4 def order @order end |
Class Method Details
.call(order:, attribute:) ⇒ Object
13 14 15 |
# File 'app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb', line 13 def self.call(order:, attribute:) new(order: order, attribute: attribute).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 |
# File 'app/services/spree_cm_commissioner/routes/base_update_order_metrics.rb', line 17 def call return unless order && attribute && SUPPORTED_ATTRIBUTES.include?(attribute) order.line_items.find_each { |li| process_line_item(li) } end |