Class: Lore::Connection
- Inherits:
-
Object
- Object
- Lore::Connection
- Defined in:
- lib/lore/connection.rb
Overview
:nodoc
Constant Summary collapse
Class Method Summary collapse
- .perform(query) ⇒ Object
- .perform_cacheable(query) ⇒ Object
- .query_count ⇒ Object
- .reset_query_count ⇒ Object
- .reset_result_row_count ⇒ Object
- .result_row_count ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
91 92 |
# File 'lib/lore/connection.rb', line 91 def initialize end |
Class Method Details
.perform(query) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/lore/connection.rb', line 118 def self.perform(query) begin connection = Context.get_connection @@query_count += 1 result = connection.exec(query) @@result_row_count += result.num_tuples # Log database query on low level: if Lore.log_queries? then query.split("\n").each { |line| @@logger.debug { line } } end rescue ::Exception => pge pge. << "\n" << query @@logger.error { pge. } @@logger.error { 'Context: ' << Context.inspect } @@logger.error { 'Query: ' << "\n" << query } raise pge end return Result.new(query, result) end |
.perform_cacheable(query) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/lore/connection.rb', line 107 def self.perform_cacheable(query) if Lore::Cache::Cached_Entities.include?(query) then result = Lore::Cache::Cached_Entities[query] else result = perform(query) Lore::Cache::Cached_Entities[query] = result end return result end |
.query_count ⇒ Object
100 101 102 |
# File 'lib/lore/connection.rb', line 100 def self.query_count @@query_count end |
.reset_query_count ⇒ Object
94 95 96 |
# File 'lib/lore/connection.rb', line 94 def self.reset_query_count @@query_count = 0 end |
.reset_result_row_count ⇒ Object
97 98 99 |
# File 'lib/lore/connection.rb', line 97 def self.reset_result_row_count @@result_row_count = 0 end |
.result_row_count ⇒ Object
103 104 105 |
# File 'lib/lore/connection.rb', line 103 def self.result_row_count @@result_row_count end |