Class: Cuprum::Collections::Scopes::Base

Inherits:
Object
  • Object
show all
Includes:
Composition
Defined in:
lib/cuprum/collections/scopes/base.rb

Overview

Abstract class representing a set of filters for a query.

Defined Under Namespace

Classes: UninvertibleScopeException

Instance Method Summary collapse

Methods included from Composition

#and, #not, #or

Constructor Details

#initializeBase

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.

Parameters:

  • other (Object)

    the object to compare.

Returns:

  • (Boolean)

    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_jsonHash{String=>Object}

Returns a JSON-compatible representation of the scope.

Returns:

  • (Hash{String=>Object})

    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

#debugObject

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.

Returns:

  • (Boolean)

    false.



43
44
45
# File 'lib/cuprum/collections/scopes/base.rb', line 43

def empty?
  false
end

#invertObject

Generates and returns an inverted copy of the scope.

Raises:



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

#typeSymbol

Returns the scope type.

Returns:

  • (Symbol)

    the scope type.



57
58
59
# File 'lib/cuprum/collections/scopes/base.rb', line 57

def type
  :abstract
end