Class: Alf::Algebra::Project

Inherits:
Object
  • Object
show all
Includes:
Operator, Relational, Unary
Defined in:
lib/alf-algebra/alf/algebra/operator/project.rb

Instance Attribute Summary

Attributes included from Operator

#operands

Attributes included from Support::Bindable

#connection

Instance Method Summary collapse

Methods included from Operator

#==, #bind, #dup, included, #initialize, #signature, #to_lispy, #to_relvar, #with_operands

Methods included from Support::Registry

decode_registered, #each, #listen, #listeners, #register, #registered

Methods included from Operand

#attr_list, coerce, #to_cog, #to_dot, #to_relation

Methods included from Support::Bindable

#bind, #bound?, #connection!

Methods included from Relational

included

Methods included from Unary

included, #operand, #with_operand

Instance Method Details

#headingObject



11
12
13
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 11

def heading
  @heading ||= operand.heading.project(attributes, allbut)
end

#key_preserving?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 21

def key_preserving?
  keys.any?{|k| operand.keys.include?(k) }
end

#keysObject



15
16
17
18
19
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 15

def keys
  @keys ||= operand.keys.select{|k|
    k.project(attributes, allbut) == k
  }.if_empty{ Keys[ heading.to_attr_list ] }
end

#stay_attributesObject



25
26
27
# File 'lib/alf-algebra/alf/algebra/operator/project.rb', line 25

def stay_attributes
  allbut ? heading.to_attr_list : attributes
end