Class: ROM::SQL::ProjectionDSL
Overview
Projection DSL used in reading API (‘select`, `select_append` etc.)
Instance Attribute Summary
Attributes inherited from DSL
#picked_relations, #relations, #schema
Instance Method Summary collapse
-
#`(value) ⇒ Attribute
Return a string literal that will be directly used in an SQL statement or query.
-
#function(name, *attrs) ⇒ Rom::SQL::Function
(also: #f)
Return a SQL function with value ‘Any`.
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Methods inherited from DSL
Constructor Details
This class inherits a constructor from ROM::SQL::DSL
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ 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.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rom/sql/projection_dsl.rb', line 52 def method_missing(meth, *args, &block) if schema.key?(meth) schema[meth] else type = type(meth) if type if args.empty? ::ROM::SQL::Function.new(type).(schema: schema) else ::ROM::SQL::Attribute[type].value(args[0]) end else super end end end |
Instance Method Details
#`(value) ⇒ Attribute
Return a string literal that will be directly used in an SQL statement or query
23 24 25 26 |
# File 'lib/rom/sql/projection_dsl.rb', line 23 def `(value) expr = ::Sequel.lit(value) ::ROM::SQL::Attribute.new(type(:string)).(sql_expr: expr) end |
#function(name, *attrs) ⇒ Rom::SQL::Function Also known as: f
Return a SQL function with value ‘Any`
39 40 41 |
# File 'lib/rom/sql/projection_dsl.rb', line 39 def function(name, *attrs) ::ROM::SQL::Function.new(::ROM::Types::Any).(schema: schema).public_send(name, *attrs) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
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.
45 46 47 |
# File 'lib/rom/sql/projection_dsl.rb', line 45 def respond_to_missing?(name, include_private = false) super || type(name) end |