Commit 13a610b

mo khan <mo@mokhan.ca>
2014-07-11 01:05:06
accept block when creating a session.
1 parent 03beb7a
Changed files (1)
lib/humble/session_factory.rb
@@ -5,7 +5,13 @@ module Humble
     end
 
     def create_session
-      Session.new(self, @configuration)
+      Session.new(self, @configuration).tap do |session|
+        begin
+          yield session if block_given?
+        ensure
+          session.dispose if block_given?
+        end
+      end
     end
 
     def create_connection