activerecord-hackery--ransack/lib/ransack/adapters/mongoid/inquiry_hash.rb

24 lines
373 B
Ruby

module Ransack
module Adapters
module Mongoid
class InquiryHash < Hash
def or(other)
{ '$or' => [ self, other] }.to_inquiry
end
def and(other)
{ '$and' => [ self, other] }.to_inquiry
end
end
end
end
end
class Hash
def to_inquiry
::Ransack::Adapters::Mongoid::InquiryHash[self]
end
end