Class: ActiveEnumerable::Where::WhereNotChain
- Inherits:
-
Object
- Object
- ActiveEnumerable::Where::WhereNotChain
- Defined in:
- lib/active_enumerable/where.rb
Instance Method Summary collapse
-
#initialize(collection, parent_class) ⇒ WhereNotChain
constructor
A new instance of WhereNotChain.
-
#not(conditions = {}) ⇒ Object
Returns a new relation expressing WHERE + NOT condition according to the conditions in the arguments.
Constructor Details
#initialize(collection, parent_class) ⇒ WhereNotChain
Returns a new instance of WhereNotChain.
6 7 8 9 |
# File 'lib/active_enumerable/where.rb', line 6 def initialize(collection, parent_class) @collection = collection @parent_class = parent_class end |
Instance Method Details
#not(conditions = {}) ⇒ Object
Returns a new relation expressing WHERE + NOT condition according to the conditions in the arguments.
#not accepts conditions as a string, array, or hash. See Where#where for more details on each format.
<#ActiveEnumerable>.where.not(name: "Jon")
<#ActiveEnumerable>.where.not(name: nil)
<#ActiveEnumerable>.where.not(name: %w(Ko1 Nobu))
<#ActiveEnumerable>.where.not(name: "Jon", role: "admin")
21 22 23 24 25 |
# File 'lib/active_enumerable/where.rb', line 21 def not(conditions={}) @parent_class.call(@collection.reject do |record| Finder.new(record).is_of(conditions) end) end |