Class: ConceptQL::Nodes::CastingNode

Inherits:
Node
  • Object
show all
Defined in:
lib/conceptql/nodes/casting_node.rb

Overview

Parent class of all casting nodes

Subclasses must implement the following methods:

  • my_type

  • i_point_at

  • these_point_at_me

i_point_at returns a list of types for which the node’s table of origin has foreign_keys pointing to another table, e.g.: procedure_occurrence has an FK to visit_occurrence, so we’d put :visit_occurrence in the i_point_at array

these_point_at_me is a list of types for which that type’s table of origin has a FK pointing to the current node’s table of origin, e.g.: procedure_cost has an FK to procedure_occurrence so we’d put :procedure_cost in procedure_occurrence’s these_point_at_me array

Also, if a casting node is passed no streams, it will return all the rows in its table as results.

Direct Known Subclasses

Death, Person, ProcedureOccurrence, VisitOccurrence

Constant Summary

Constants inherited from Node

Node::KNOWN_TYPES

Instance Attribute Summary

Attributes inherited from Node

#values

Instance Method Summary collapse

Methods inherited from Node

#arguments, #children, #columns, #date_columns, #evaluate, #initialize, #select_it, #stream

Constructor Details

This class inherits a constructor from ConceptQL::Nodes::Node

Instance Method Details

#castablesObject



30
31
32
# File 'lib/conceptql/nodes/casting_node.rb', line 30

def castables
  (i_point_at + these_point_at_me)
end

#query(db) ⇒ Object



34
35
36
37
# File 'lib/conceptql/nodes/casting_node.rb', line 34

def query(db)
  return db.from(make_table_name(my_type)) if stream.nil?
  base_query(db, stream.evaluate(db))
end

#typesObject



26
27
28
# File 'lib/conceptql/nodes/casting_node.rb', line 26

def types
  [my_type]
end