class Axiom::Relation::Variable

A relation variable

Public Class Methods

new(relation) click to toggle source

Instantiate a new relation variable

@example

relvar = Relation::Variable.new(relation)

@param [Relation] relation

@return [Relation::Variable]

@api public

Calls superclass method Axiom::Relation::new
# File lib/axiom/relation/variable.rb, line 20
def self.new(relation)
  if equal?(Variable) && relation.materialized?
    Materialized.new(relation)
  else
    super
  end
end
new(relation) click to toggle source

Initialize a relation variable

@param [Relation] relation

@return [undefined]

@api private

# File lib/axiom/relation/variable.rb, line 35
def initialize(relation)
  @relation = relation
  @mutex    = Mutex.new
end

Public Instance Methods

delete(other) click to toggle source

Delete tuples from the relation variable

@example

relvar.delete(other)

@param [Enumerable] other

@return [self]

@api public

# File lib/axiom/relation/variable.rb, line 65
def delete(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end
insert(other) click to toggle source

Insert tuples into the relation variable

@example

relvar.insert(other)

@param [Enumerable] other

@return [self]

@api public

# File lib/axiom/relation/variable.rb, line 50
def insert(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end
replace(other) click to toggle source

Replace the relation variable with new tuples

@example

relvar.replace(other)

@param [Enumerable] other

@return [self]

@api public

# File lib/axiom/relation/variable.rb, line 80
def replace(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end

Private Instance Methods

mutate_relation(*args) click to toggle source

Mutate the relation variable

@param [Symbol] method @param [Enumerable] other

@return [undefined]

@api private

# File lib/axiom/relation/variable.rb, line 95
def mutate_relation(*args)
  @relation = relation.public_send(*args)
end