diff options
| author | mo khan <mo@mokhan.ca> | 2014-07-10 19:05:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-07-10 19:05:06 -0600 |
| commit | 13a610b579b4b0494136c3c64208a8bc02626304 (patch) | |
| tree | d687adce0ee50e047083329e99ccfc3f1653ad47 | |
| parent | 03beb7a1e653f6995fe176ecbeee9de92f40f1c4 (diff) | |
accept block when creating a session.
| -rw-r--r-- | lib/humble/session_factory.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/humble/session_factory.rb b/lib/humble/session_factory.rb index f76fb39..2d4b29d 100644 --- a/lib/humble/session_factory.rb +++ b/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 |
