Class: Hyperion::Sql::QueryExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion/sql/query_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#strategyObject (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

#connectionObject



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