Skip to content

Instantly share code, notes, and snippets.

@romanlehnert
Last active August 29, 2015 14:16
Show Gist options
  • Save romanlehnert/b9b8584abf766b28c844 to your computer and use it in GitHub Desktop.
Save romanlehnert/b9b8584abf766b28c844 to your computer and use it in GitHub Desktop.
Matcher pattern
invoice = Invoice.last
invoice.load_order_matches.with_score_gt(70) # <= LoadOrderMatchesCollection
best_match = invoice.load_order_matches.best # <= LoadOrderMatch
best_match.score # <= 97
best_match.invoice # <= Invoice
best_match.load_order # <= LoadOrder
best_match.similarities # <= [ amount: 500 ]
class Invoice
extend Matchability
matchable_with :load_order
end
class LoadOrder
extend Matchability
matchable_with :invoice
end
class InvoiceLoadOrderMatch < ScoreMatch
attr_reader :invoice
attr_reader :load_order
def score
# calcuate score here
end
def similarities
#
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment