Class: Centra::Rule::OrderMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/centra/rule/order_matcher.rb

Overview

Match Centra orders with Rule sent emails

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orders_data) ⇒ OrderMatcher

# centra_orders & rule_orders types are Array<Order> data = {

'[email protected]' => { centra_orders: [], rule_orders: [] }

}

MatchOrders.new(data)

Examples:

Simple example

Parameters:

  • orders_data (OrdersData)


14
15
16
17
18
19
20
# File 'lib/centra/rule/order_matcher.rb', line 14

def initialize(orders_data)
  @matched_orders = []
  @missing_order_emails = []
  @data = orders_data

  perform(orders_data.email_orders)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/centra/rule/order_matcher.rb', line 5

def data
  @data
end

Instance Method Details

#matchedHash

Returns the matched orders.

Examples:

order_matcher.matched
# => { rule: #<Order:0x07f..>, centra: #<Order:0x09d..> }

Returns:

  • (Hash)

    the matched orders



26
27
28
# File 'lib/centra/rule/order_matcher.rb', line 26

def matched
  @matched_orders
end

#missingArray<Order>

Returns the Centra order that has no match.

Returns:

  • (Array<Order>)

    the Centra order that has no match



31
32
33
# File 'lib/centra/rule/order_matcher.rb', line 31

def missing
  @missing_order_emails
end