Module: Mongoid::Criterion::Builder
- Included in:
- Mongoid::Criteria
- Defined in:
- lib/mongoid/criterion/builder.rb
Overview
This module defines criteria behavior for building documents for specified conditions.
Instance Method Summary collapse
-
#build(attrs = {}) ⇒ Document
Build a document given the selector and return it.
Instance Method Details
#build(attrs = {}) ⇒ Document
Build a document given the selector and return it. Complex criteria, such as $in and $or operations will get ignored.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mongoid/criterion/builder.rb', line 21 def build(attrs = {}) klass.new( selector.inject(attrs) do |hash, (key, value)| hash.tap do |attrs| unless key.to_s =~ /\$/ || value.is_a?(Hash) attrs[key] = value end end end ) end |