Skip to content

Instantly share code, notes, and snippets.

@adelevie
Last active February 11, 2016 21:02
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 adelevie/de68e07a1064ddf89828 to your computer and use it in GitHub Desktop.
Save adelevie/de68e07a1064ddf89828 to your computer and use it in GitHub Desktop.
module AuctionQuery
class Base
def initialize(relation = Auction.all)
@relation = relation
end
end
class DeliveryDeadlineExpired < Base
def call
@relation.where('delivery_deadline < ?', Time.zone.now)
end
end
class Accepted < Base
def call
@relation.where(result: 'accepted')
end
end
class Delivered < Base
def call
@relation.where.not(delivery_url: [nil, ""])
end
end
class CapSubmitted < Base
@relation.where.not(cap_proposal_url: [nil, ""])
end
class Paid < Base
@relation.where(awardee_paid_status: 'paid')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment