class TestQuery < SimpleDelegator
def initialize
super(Bomb.all.extending(Scopes))
end
module Scopes
def processed
where(Bomb.arel_table[:asset_remote_url].eq(nil))
end
end
end
q = TestQuery.new
q.__getobj__.class # <= q is a decorated Active Record Association Relation
=> Bomb::ActiveRecord_Relation
q.to_sql
=> "SELECT \"bombs\".* FROM \"bombs\""
q.processed.to_sql
=> "SELECT \"bombs\".* FROM \"bombs\" WHERE \"bombs\".\"asset_remote_url\" IS NULL"