class ConceptQL::Operators::Numeric
Represents a operator that will either:
-
create a value_as_number value for every person in the database
-
change the value_as_number value for every every result passed in
-
either to a number
-
or a value from a column in the origin row
-
Accepts two params:
-
Either a number value or a symbol representing a column name
-
An optional stream
Public Instance Methods
domains(db)
click to toggle source
Calls superclass method
# File lib/conceptql/operators/numeric.rb, line 43 def domains(db) stream.nil? ? [:person] : super end
query(db)
click to toggle source
# File lib/conceptql/operators/numeric.rb, line 39 def query(db) stream.nil? ? as_criterion(db) : with_kids(db) end
query_cols()
click to toggle source
# File lib/conceptql/operators/numeric.rb, line 35 def query_cols dynamic_columns - [:value_as_number] + [:value_as_number] end
Private Instance Methods
as_criterion(db)
click to toggle source
# File lib/conceptql/operators/numeric.rb, line 55 def as_criterion(db) db.from(select_it(db.from(:person).clone(:force_columns=>table_columns(:person)), :person)) .select(*(dynamic_columns - [:value_as_number])) .select_append(first_argument.cast(Float).as(:value_as_number)) .from_self end
first_argument()
click to toggle source
# File lib/conceptql/operators/numeric.rb, line 62 def first_argument case arguments.first when String Sequel.identifier(arguments.first) else Sequel.expr(arguments.first) end end
with_kids(db)
click to toggle source
# File lib/conceptql/operators/numeric.rb, line 48 def with_kids(db) db.from(stream.evaluate(db)) .select(*(dynamic_columns - [:value_as_number])) .select_append(first_argument.cast(Float).as(:value_as_number)) .from_self end