Class: Theme::ThreadUtility

Inherits:
Object
  • Object
show all
Defined in:
lib/theme/events.rb

Class Method Summary collapse

Class Method Details

.with_connection(&block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/theme/events.rb', line 3

def self.with_connection(&block)
  begin
    yield block
  rescue Exception => e
    raise e
  ensure
    # Check the connection back in to the connection pool
    if defined?(ActiveRecord) && ActiveRecord::Base.connection
      ActiveRecord::Base.connection.close
    end
  end
end