Class: ConceptQL::Operators::CastingOperator

Inherits:
Operator
  • Object
show all
Defined in:
lib/conceptql/operators/casting_operator.rb

Overview

Parent class of all casting operators

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 operator’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 operator’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 operator is passed no streams, it will return all the rows in its table as results.

Constant Summary

Constants inherited from Operator

Operator::COLUMNS

Instance Attribute Summary

Attributes inherited from Operator

#arguments, #options, #upstreams, #values

Instance Method Summary collapse

Methods inherited from Operator

#columns, #evaluate, #initialize, #label, #select_it, #set_values, #sql, #stream

Methods included from Metadatable

#allows_many_upstreams, #allows_one_upstream, #argument, #category, #desc, #humanized_class_name, #inherited, #just_class_name, #option, #predominant_types, #preferred_name, #reset_categories, #to_metadata

Constructor Details

This class inherits a constructor from ConceptQL::Operators::Operator

Instance Method Details

#castablesObject



35
36
37
# File 'lib/conceptql/operators/casting_operator.rb', line 35

def castables
  (i_point_at + these_point_at_me)
end

#query(db) ⇒ Object



39
40
41
42
# File 'lib/conceptql/operators/casting_operator.rb', line 39

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

#typeObject



31
32
33
# File 'lib/conceptql/operators/casting_operator.rb', line 31

def type
  my_type
end

#typesObject



27
28
29
# File 'lib/conceptql/operators/casting_operator.rb', line 27

def types
  [type]
end