Class: ROM::SQL::DSL Private
- Inherits:
- BasicObject
- Defined in:
- lib/rom/sql/dsl.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.
Direct Known Subclasses
Instance Attribute Summary collapse
- #picked_relations ⇒ Object readonly private
- #relations ⇒ Object readonly private
- #schema ⇒ Object readonly private
Instance Method Summary collapse
-
#`(value) ⇒ Sequel::LiteralString
Return a string literal that will be used directly in an ORDER clause.
- #call(&block) ⇒ Object private
-
#exists(relation) ⇒ Object
Returns a result of SQL EXISTS clause.
-
#initialize(schema) ⇒ DSL
constructor
private
A new instance of DSL.
- #respond_to_missing?(name, include_private = false) ⇒ Boolean private
Constructor Details
#initialize(schema) ⇒ DSL
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.
Returns a new instance of DSL.
22 23 24 25 26 |
# File 'lib/rom/sql/dsl.rb', line 22 def initialize(schema) @schema = schema @relations = schema.respond_to?(:relations) ? schema.relations : EMPTY_HASH @picked_relations = ::Concurrent::Map.new end |
Instance Attribute Details
#picked_relations ⇒ Object (readonly)
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 |
# File 'lib/rom/sql/dsl.rb', line 19 def picked_relations @picked_relations end |
#relations ⇒ Object (readonly)
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/dsl.rb', line 15 def relations @relations end |
#schema ⇒ Object (readonly)
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.
11 12 13 |
# File 'lib/rom/sql/dsl.rb', line 11 def schema @schema end |
Instance Method Details
#`(value) ⇒ Sequel::LiteralString
Return a string literal that will be used directly in an ORDER clause
46 47 48 |
# File 'lib/rom/sql/dsl.rb', line 46 def `(value) ::Sequel.lit(value) end |
#call(&block) ⇒ 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.
29 30 31 32 33 34 35 36 37 |
# File 'lib/rom/sql/dsl.rb', line 29 def call(&block) result = instance_exec(select_relations(block.parameters), &block) if result.is_a?(::Array) result else [result] end end |
#exists(relation) ⇒ Object
Returns a result of SQL EXISTS clause.
57 58 59 |
# File 'lib/rom/sql/dsl.rb', line 57 def exists(relation) ::ROM::SQL::Attribute[Types::Bool].(sql_expr: relation.dataset.exists) 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.
62 63 64 |
# File 'lib/rom/sql/dsl.rb', line 62 def respond_to_missing?(name, include_private = false) super || schema.key?(name) end |