Module: Cuprum::Collections::Scopes::Composition
- Included in:
- Base
- Defined in:
- lib/cuprum/collections/scopes/composition.rb
Overview
Defines a fluent interface for composing scopes.
Instance Method Summary collapse
- #and(*args) ⇒ Object (also: #where)
- #not ⇒ Object
- #or(*args) ⇒ Object
Instance Method Details
#and(hash = nil, &block) ⇒ Object #and(scope) ⇒ Object Also known as: where
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cuprum/collections/scopes/composition.rb', line 17 def and(*args, &) if scope?(args.first) return and_scope(args.first) || and_generic_scope(args.first) end scope = builder.build(*args, &) # We control the current and generated scopes, so we can skip validation # and transformation. builder.build_conjunction_scope(scopes: [self, scope], safe: false) end |
#not(hash = nil, &block) ⇒ Object #not(scope) ⇒ Object
39 40 41 42 43 |
# File 'lib/cuprum/collections/scopes/composition.rb', line 39 def not(...) scope = builder.build(...).invert self.and(scope) end |
#and(hash = nil, &block) ⇒ Object #and(scope) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cuprum/collections/scopes/composition.rb', line 54 def or(*args, &) if scope?(args.first) return or_scope(args.first) || or_generic_scope(args.first) end scope = builder.build(*args, &) # We control the current and generated scopes, so we can skip validation # and transformation. builder.build_disjunction_scope(scopes: [self, scope], safe: false) end |