Class: Hyperion::Sql::QueryExecutor
- Inherits:
-
Object
- Object
- Hyperion::Sql::QueryExecutor
- Defined in:
- lib/hyperion/sql/query_executor.rb
Instance Attribute Summary collapse
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
- #connection ⇒ Object
- #execute_mutation(sql_query) ⇒ Object
- #execute_query(sql_query) ⇒ Object
- #execute_write(sql_query) ⇒ Object
-
#initialize(strategy) ⇒ QueryExecutor
constructor
A new instance of QueryExecutor.
Constructor Details
#initialize(strategy) ⇒ QueryExecutor
Returns a new instance of QueryExecutor.
10 11 12 |
# File 'lib/hyperion/sql/query_executor.rb', line 10 def initialize(strategy) @strategy = strategy end |
Instance Attribute Details
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
8 9 10 |
# File 'lib/hyperion/sql/query_executor.rb', line 8 def strategy @strategy end |
Instance Method Details
#connection ⇒ Object
28 29 30 |
# File 'lib/hyperion/sql/query_executor.rb', line 28 def connection Sql.connection end |
#execute_mutation(sql_query) ⇒ Object
14 15 16 17 |
# File 'lib/hyperion/sql/query_executor.rb', line 14 def execute_mutation(sql_query) command = connection.create_command(sql_query.query_str) command.execute_non_query(*sql_query.bind_values) end |
#execute_query(sql_query) ⇒ Object
19 20 21 22 |
# File 'lib/hyperion/sql/query_executor.rb', line 19 def execute_query(sql_query) command = connection.create_command(sql_query.query_str) command.execute_reader(*sql_query.bind_values).to_a end |
#execute_write(sql_query) ⇒ Object
24 25 26 |
# File 'lib/hyperion/sql/query_executor.rb', line 24 def execute_write(sql_query) strategy.execute_write(sql_query) end |