Class: Cuprum::Collections::Scopes::Base
- Inherits:
-
Object
- Object
- Cuprum::Collections::Scopes::Base
- Includes:
- Composition
- Defined in:
- lib/cuprum/collections/scopes/base.rb
Overview
Abstract class representing a set of filters for a query.
Direct Known Subclasses
Basic::Scopes::Base, AllScope, ConjunctionScope, CriteriaScope, DisjunctionScope, NoneScope
Defined Under Namespace
Classes: UninvertibleScopeException
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
True if the other object is a scope with matching type; otherwise false.
-
#as_json ⇒ Hash{String=>Object}
A JSON-compatible representation of the scope.
-
#debug ⇒ Object
Generates a string representation of the scope.
-
#empty? ⇒ Boolean
False.
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#invert ⇒ Object
Generates and returns an inverted copy of the scope.
-
#type ⇒ Symbol
The scope type.
Methods included from Composition
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
14 |
# File 'lib/cuprum/collections/scopes/base.rb', line 14 def initialize(**); end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the other object is a scope with matching type; otherwise false.
20 21 22 23 24 |
# File 'lib/cuprum/collections/scopes/base.rb', line 20 def ==(other) return false unless other.is_a?(Cuprum::Collections::Scopes::Base) other.type == type end |
#as_json ⇒ Hash{String=>Object}
Returns a JSON-compatible representation of the scope.
28 29 30 |
# File 'lib/cuprum/collections/scopes/base.rb', line 28 def as_json { 'type' => type } end |
#debug ⇒ Object
Generates a string representation of the scope.
37 38 39 |
# File 'lib/cuprum/collections/scopes/base.rb', line 37 def debug debug_class_name(self) end |
#empty? ⇒ Boolean
Returns false.
43 44 45 |
# File 'lib/cuprum/collections/scopes/base.rb', line 43 def empty? false end |
#invert ⇒ Object
Generates and returns an inverted copy of the scope.
51 52 53 54 |
# File 'lib/cuprum/collections/scopes/base.rb', line 51 def invert raise UninvertibleScopeException, "Scope class #{self.class.name} does not implement #invert" end |
#type ⇒ Symbol
Returns the scope type.
57 58 59 |
# File 'lib/cuprum/collections/scopes/base.rb', line 57 def type :abstract end |