Skip to content

Instantly share code, notes, and snippets.

@colindensem
Created June 3, 2021 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colindensem/54feb084995d6176c054d9cf06c12eff to your computer and use it in GitHub Desktop.
Save colindensem/54feb084995d6176c054d9cf06c12eff to your computer and use it in GitHub Desktop.
DataFinder using method() approach
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
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