Class: ROM::SQL::Function Private
- Inherits:
-
ROM::Schema::Attribute
- Object
- ROM::Schema::Attribute
- ROM::SQL::Function
- Defined in:
- lib/rom/sql/function.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#cast(expr, db_type) ⇒ ROM::SQL::Attribute
private
Convert an expression result to another data type.
- #is(other) ⇒ Object private
- #name ⇒ Object private
- #qualified ⇒ Object private
- #sql_literal(ds) ⇒ Object private
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rom/sql/function.rb', line 50 def method_missing(meth, *args) if func if func.respond_to?(meth) (func: func.__send__(meth, *args)) else super end else (func: Sequel::SQL::Function.new(meth.to_s.upcase, *args)) end end |
Instance Method Details
#cast(expr, db_type) ⇒ ROM::SQL::Attribute
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert an expression result to another data type
40 41 42 |
# File 'lib/rom/sql/function.rb', line 40 def cast(expr, db_type) Attribute[type].(sql_expr: ::Sequel.cast(expr, db_type)) end |
#is(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/rom/sql/function.rb', line 25 def is(other) ::Sequel::SQL::BooleanExpression.new(:'=', func, other) end |
#name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/rom/sql/function.rb', line 15 def name [:alias] || super end |
#qualified ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 |
# File 'lib/rom/sql/function.rb', line 19 def qualified ( func: ::Sequel::SQL::Function.new(func.name, *func.args.map { |arg| arg.respond_to?(:qualified) ? arg.qualified : arg }) ) end |
#sql_literal(ds) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 |
# File 'lib/rom/sql/function.rb', line 7 def sql_literal(ds) if name ds.literal(func.as(name)) else ds.literal(func) end end |