Class: Axiom::Relation::Variable

Inherits:
Axiom::Relation show all
Includes:
Adamantium::Mutable, Proxy
Defined in:
lib/axiom/relation/variable.rb

Overview

A relation variable

Direct Known Subclasses

Materialized

Defined Under Namespace

Classes: Materialized

Constant Summary

Constants included from Proxy

Proxy::ENUMERABLE_METHODS, Proxy::PROXY_METHODS, Proxy::RELATION_METHODS, Proxy::REMOVE_METHODS

Instance Attribute Summary

Attributes inherited from Axiom::Relation

#header

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Proxy

#respond_to?

Methods inherited from Axiom::Relation

#==, #[], #directions, #each, #empty?, #include?, #materialize, #materialized?

Methods included from Visitable

#accept

Constructor Details

#initialize(relation) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a relation variable

Parameters:



35
36
37
38
# File 'lib/axiom/relation/variable.rb', line 35

def initialize(relation)
  @relation = relation
  @mutex    = Mutex.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Axiom::Relation::Proxy

Class Method Details

.new(relation) ⇒ Relation::Variable

Instantiate a new relation variable

Examples:

relvar = Relation::Variable.new(relation)

Parameters:

Returns:



20
21
22
23
24
25
26
# File 'lib/axiom/relation/variable.rb', line 20

def self.new(relation)
  if equal?(Variable) && relation.materialized?
    Materialized.new(relation)
  else
    super
  end
end

Instance Method Details

#delete(other) ⇒ self

Delete tuples from the relation variable

Examples:

relvar.delete(other)

Parameters:

  • other (Enumerable)

Returns:

  • (self)


65
66
67
68
# File 'lib/axiom/relation/variable.rb', line 65

def delete(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end

#insert(other) ⇒ self

Insert tuples into the relation variable

Examples:

relvar.insert(other)

Parameters:

  • other (Enumerable)

Returns:

  • (self)


50
51
52
53
# File 'lib/axiom/relation/variable.rb', line 50

def insert(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end

#replace(other) ⇒ self

Replace the relation variable with new tuples

Examples:

relvar.replace(other)

Parameters:

  • other (Enumerable)

Returns:

  • (self)


80
81
82
83
# File 'lib/axiom/relation/variable.rb', line 80

def replace(other)
  @mutex.synchronize { mutate_relation(__method__, other) }
  self
end