Class: Veritas::Adapter::DataObjects::Statement
- Inherits:
-
Object
- Object
- Veritas::Adapter::DataObjects::Statement
- Includes:
- Enumerable, Immutable
- Defined in:
- lib/veritas/adapter/data_objects/statement.rb
Overview
Executes generated SQL statements
Instance Method Summary collapse
-
#each {|row| ... } ⇒ self
Iterate over each row in the results.
-
#initialize(connection, relation, visitor = SQL::Generator::Relation) ⇒ undefined
constructor
private
Initialize a statement.
-
#to_s ⇒ String
Return the SQL query.
Constructor Details
#initialize(connection, relation, visitor = SQL::Generator::Relation) ⇒ undefined
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.
Initialize a statement
23 24 25 26 27 |
# File 'lib/veritas/adapter/data_objects/statement.rb', line 23 def initialize(connection, relation, visitor = SQL::Generator::Relation) @connection = connection @relation = relation @visitor = visitor end |
Instance Method Details
#each {|row| ... } ⇒ self
Iterate over each row in the results
43 44 45 46 47 |
# File 'lib/veritas/adapter/data_objects/statement.rb', line 43 def each return to_enum unless block_given? each_row { |row| yield row } self end |
#to_s ⇒ String
Return the SQL query
57 58 59 |
# File 'lib/veritas/adapter/data_objects/statement.rb', line 57 def to_s @visitor.visit(@relation).to_sql.freeze end |