Class: Locomotive::RelationalAlgebra::Project

Inherits:
Unary show all
Defined in:
lib/locomotive/relational_algebra/operators/projections/projection.rb

Instance Attribute Summary

Attributes inherited from Operator

#schema

Attributes included from AstHelpers::AstNode

#kind, #left_child, #owner, #right_child, #value

Instance Method Summary collapse

Methods inherited from Operator

#bound, #free, #to_xml, #xml_kind, #xml_schema

Methods included from XML

included, #quote, #to_xml

Methods included from AstHelpers::Annotations

#method_missing, #respond_to?

Methods included from AstHelpers::AstNode

#has_left_child?, #has_right_child?, #is_leaf?, #traverse, #traverse_strategy=

Constructor Details

#initialize(op, proj_list) ⇒ Project

Returns a new instance of Project.



68
69
70
71
# File 'lib/locomotive/relational_algebra/operators/projections/projection.rb', line 68

def initialize(op, proj_list)
  @proj_list = to_project_list proj_list
  super(op)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Locomotive::AstHelpers::Annotations

Instance Method Details

#child=(op) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/locomotive/relational_algebra/operators/projections/projection.rb', line 73

def child=(op)
  unless op.schema.attributes?(proj_list.old_items)
    raise CorruptedSchema,
          "Schema #{op.schema.attributes} does not " \
          "contain all attributes of #{proj_list.old_items}."
  end
  proj_list.old_items.each do |old|
    proj_list[old].each do |new|
      schema[new] = op.schema[old]
    end
  end
  super(op)
end

#cloneObject



93
94
95
# File 'lib/locomotive/relational_algebra/operators/projections/projection.rb', line 93

def clone
  Project.new(child.clone, proj_list.clone)
end

#set(var, plan) ⇒ Object



97
98
99
100
101
# File 'lib/locomotive/relational_algebra/operators/projections/projection.rb', line 97

def set(var,plan)
  Project.new(
    child.set(var,plan),
    proj_list.clone)
end

#xml_contentObject



87
88
89
90
91
# File 'lib/locomotive/relational_algebra/operators/projections/projection.rb', line 87

def xml_content
  content do
    proj_list.to_xml
  end
end