Sha256: cce350de1e9dd5f7083b9e4cf5587420791325a2799c2c975fa9578f63bcbe7d
Contents?: true
Size: 1.05 KB
Versions: 17
Compression:
Stored size: 1.05 KB
Contents
# encoding: utf-8 require "mongoid/matchers/default" require "mongoid/matchers/all" require "mongoid/matchers/exists" require "mongoid/matchers/gt" require "mongoid/matchers/gte" require "mongoid/matchers/in" require "mongoid/matchers/lt" require "mongoid/matchers/lte" require "mongoid/matchers/ne" require "mongoid/matchers/nin" require "mongoid/matchers/size" module Mongoid #:nodoc: module Matchers # Determines if this document has the attributes to match the supplied # MongoDB selector. Used for matching on embedded associations. def matches?(selector) selector.each_pair do |key, value| return false unless matcher(key, value).matches?(value) end; true end protected # Get the matcher for the supplied key and value. Will determine the class # name from the key. def matcher(key, value) if value.is_a?(Hash) name = "Mongoid::Matchers::#{value.keys.first.gsub("$", "").camelize}" return name.constantize.new(attributes[key]) end Default.new(attributes[key]) end end end
Version data entries
17 entries across 17 versions & 3 rubygems