Module: Axiom::Algebra::Restriction::Methods

Defined in:
lib/axiom/algebra/restriction.rb

Instance Method Summary collapse

Instance Method Details

#restrict(*args) {|context| ... } ⇒ Restriction

Return a relation with restricted tuples

Examples:

restriction with a predicate

restriction = relation.restrict(predicate)

restriction using a block

restriction = relation.restrict do |context|
  context.a.eq('other').and(context.b.gte(42))
end

restriction using a Hash

restriction = relation.restrict(id: 1)

restriction using an Array

restriction = relation.restrict([[:id, 1]])

Parameters:

  • args (Array)

    optional arguments

Yields:

  • (context)

    optional block to restrict the tuples with

Yield Parameters:

Yield Returns:

  • (Function, #call)

    predicate to restrict the tuples with

Returns:



124
125
126
# File 'lib/axiom/algebra/restriction.rb', line 124

def restrict(*args, &block)
  Restriction.new(self, coerce_to_predicate(*args, &block))
end