To be clear, I'm using your implementation as a reference and not importing it directly, so it's likely I'm missing something!
If I use a query object like this:
module Transactions
class AcceptedQuery < Patterns::Query
queries Transaction
private
def query
relation.active.where(accepted_at: 5.days.ago..DateTime.current)
end
end
end
class Transaction < ActiveRecord::Base
scope :latest, -> { order(created_at: :desc) }
scope :query_object_scope, Transactions::AcceptedQuery
end
If I try to compose the scopes:
Transaction.latest.accepted
Transactions::AcceptedQuery.call will not receive Transaction.latest as the scope argument, but rather it's base_relation ie: Transaction.all. Am I looking at this right? Is there a workaround for this other than using a class method?
I like the elegance of scope :accepted, Transactions::AcceptedQuery but I can't get it to work.
Thank you for your time and energy! I've learned a lot from this Repo already!
To be clear, I'm using your implementation as a reference and not importing it directly, so it's likely I'm missing something!
If I use a query object like this:
If I try to compose the scopes:
Transactions::AcceptedQuery.callwill not receiveTransaction.latestas the scope argument, but rather it'sbase_relationie:Transaction.all. Am I looking at this right? Is there a workaround for this other than using a class method?I like the elegance of
scope :accepted, Transactions::AcceptedQuerybut I can't get it to work.Thank you for your time and energy! I've learned a lot from this Repo already!