Last active
August 29, 2015 14:16
-
-
Save romanlehnert/b9b8584abf766b28c844 to your computer and use it in GitHub Desktop.
Matcher pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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