Class: Cuprum::Collections::Basic::Scopes::CriteriaScope
- Inherits:
-
Base
- Object
- Scopes::Base
- Base
- Cuprum::Collections::Basic::Scopes::CriteriaScope
- Includes:
- Scopes::Criteria
- Defined in:
- lib/cuprum/collections/basic/scopes/criteria_scope.rb
Overview
Scope for filtering on basic collection data based on criteria.
Instance Attribute Summary
Attributes included from Scopes::Criteria
Instance Method Summary collapse
-
#match?(item:) ⇒ Boolean
(also: #matches?)
Returns true if the provided item matches the configured criteria.
Methods included from Scopes::Criteria
#==, #and, #as_json, #debug, #empty?, #initialize, #invert, #inverted?, #or, #type, #with_criteria
Methods inherited from Base
Methods inherited from Scopes::Base
#==, #as_json, #debug, #empty?, #initialize, #invert, #type
Methods included from Scopes::Composition
Instance Method Details
#match?(item:) ⇒ Boolean Also known as: matches?
Returns true if the provided item matches the configured criteria.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/cuprum/collections/basic/scopes/criteria_scope.rb', line 51 def match?(item:) super if inverted? criteria.any? do |(attribute, operator, value)| filter_for(operator).call(item, attribute, value) end else criteria.all? do |(attribute, operator, value)| filter_for(operator).call(item, attribute, value) end end end |