Created
June 3, 2021 10:24
-
-
Save colindensem/54feb084995d6176c054d9cf06c12eff to your computer and use it in GitHub Desktop.
DataFinder using method() approach
This file contains hidden or 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
module Accounting | |
class PaymentsFinder < BaseFinder | |
def default_model | |
Payments | |
end | |
def query | |
( | |
method(:by_transfer_to_id) >> | |
method(:by_transfer_from_id) >> | |
method(:by_transfer_id) >> | |
method(:by_transfer_type) >> | |
method(:by_created_at_before) >> | |
method(:by_created_at_after) | |
).call(model.all) | |
end | |
end | |
end |
This file contains hidden or 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
module Accounting | |
class PaymentsFinder < BaseFinder | |
def default_model | |
Payments | |
end | |
def query | |
collection = model | |
collection = by_transfer_to_id(collection) | |
collection = by_transfer_from_id(collection) | |
collection = by_transfer_id(collection) | |
collection = by_transfer_type(collection) | |
collection = by_created_at_before(collection) | |
collection = by_created_at_after(collection) | |
collection | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment