Class: Axiom::Algebra::Rename

Inherits:
Relation
  • Object
show all
Includes:
Relation::Operation::Unary
Defined in:
lib/axiom/algebra/rename.rb,
lib/axiom/algebra/rename/aliases.rb

Overview

Rename attributes in the header

Defined Under Namespace

Modules: Methods Classes: Aliases

Instance Attribute Summary collapse

Attributes included from Operation::Unary

#operand

Attributes inherited from Relation

#header

Instance Method Summary collapse

Methods inherited from Relation

#==, #[], #empty?, #include?, #materialize, #materialized?, new, #one, #replace

Methods included from Visitable

#accept

Constructor Details

#initialize(operand, aliases) ⇒ 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 Rename

Parameters:

  • operand (Relation)

    the relation to rename

  • aliases (Hash, Aliases)

    the old and new attribute names



35
36
37
38
39
40
# File 'lib/axiom/algebra/rename.rb', line 35

def initialize(operand, aliases)
  super(operand)
  @aliases    = Aliases.coerce(@header, aliases)
  @header     = @header.rename(@aliases)
  @directions = operand.directions.rename(@aliases)
end

Instance Attribute Details

#aliasesAliases (readonly)

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.

The aliases for the relation

Returns:



16
17
18
# File 'lib/axiom/algebra/rename.rb', line 16

def aliases
  @aliases
end

#directionsOperation::Order::DirectionSet (readonly)

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.

The relation sort order



23
24
25
# File 'lib/axiom/algebra/rename.rb', line 23

def directions
  @directions
end

Instance Method Details

#delete(other) ⇒ Rename

Delete a relation from the Rename

Examples:

new_relation = rename.delete(other)

Parameters:

Returns:



87
88
89
90
# File 'lib/axiom/algebra/rename.rb', line 87

def delete(other)
  other = coerce(other)
  operand.delete(other.rename(aliases.inverse)).rename(aliases)
end

#each {|tuple| ... } ⇒ self

Iterate over each tuple in the set

Examples:

rename = Rename.new(operand, aliases)
rename.each { |tuple| ... }

Yields:

  • (tuple)

Yield Parameters:

  • tuple (Tuple)

    each tuple in the set

Returns:

  • (self)


56
57
58
59
60
# File 'lib/axiom/algebra/rename.rb', line 56

def each
  return to_enum unless block_given?
  operand.each { |operand_tuple| yield Tuple.new(header, operand_tuple.to_ary) }
  self
end

#insert(other) ⇒ Rename

Insert a relation into the Rename

Examples:

new_relation = rename.insert(other)

Parameters:

Returns:



72
73
74
75
# File 'lib/axiom/algebra/rename.rb', line 72

def insert(other)
  other = coerce(other)
  operand.insert(other.rename(aliases.inverse)).rename(aliases)
end