Module: Cuprum::Collections::Scopes::Disjunction

Includes:
Container
Included in:
Basic::Scopes::DisjunctionScope, DisjunctionScope
Defined in:
lib/cuprum/collections/scopes/disjunction.rb

Overview

Functionality for implementing a logical OR scope.

Instance Attribute Summary

Attributes included from Container

#scopes

Instance Method Summary collapse

Methods included from Container

#==, #as_json, #debug, #empty?, #initialize, #with_scopes

Instance Method Details

#invertCuprum::Collections::Disjunction

Returns a logical AND scope with the constituent scopes inverted.

Returns:

  • (Cuprum::Collections::Disjunction)

    a logical AND scope with the constituent scopes inverted.



13
14
15
# File 'lib/cuprum/collections/scopes/disjunction.rb', line 13

def invert
  builder.build_conjunction_scope(scopes: scopes.map(&:invert))
end

#and(hash = nil, &block) ⇒ Object #and(scope) ⇒ Object

Overloads:

  • #and(hash = nil, &block) ⇒ Object

    Parses the hash or block and combines using a logical OR.

    See Also:

    • Criteria::Parser#parse.
  • #and(scope) ⇒ Object

    Combines with the current scope using a logical OR.

    Returns self if the given scope is empty.



18
19
20
21
22
23
24
# File 'lib/cuprum/collections/scopes/disjunction.rb', line 18

def or(*args, &)
  return super if scope?(args.first)

  scope = builder.build(*args, &)

  with_scopes([*scopes, scope])
end

#typeSymbol

Returns the scope type.

Returns:

  • (Symbol)

    the scope type.



27
28
29
# File 'lib/cuprum/collections/scopes/disjunction.rb', line 27

def type
  :disjunction
end