Module: Cuprum::Collections::Scopes::Conjunction

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

Overview

Functionality for implementing a logical AND 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

#and(hash = nil, &block) ⇒ Object #and(scope) ⇒ Object Also known as: where

Overloads:

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

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

    See Also:

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

    Combines with the current scope using a logical AND.

    Returns self if the given scope is empty.



12
13
14
15
16
# File 'lib/cuprum/collections/scopes/conjunction.rb', line 12

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

  with_scopes([*scopes, builder.build(*args, &)])
end

#invertCuprum::Collections::Disjunction

Returns a logical OR scope with the constituent scopes inverted.

Returns:

  • (Cuprum::Collections::Disjunction)

    a logical OR scope with the constituent scopes inverted.



21
22
23
# File 'lib/cuprum/collections/scopes/conjunction.rb', line 21

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

#typeSymbol

Returns the scope type.

Returns:

  • (Symbol)

    the scope type.



26
27
28
# File 'lib/cuprum/collections/scopes/conjunction.rb', line 26

def type
  :conjunction
end