Class Ribs::Handle
In: lib/ribs/handle.rb
Parent: Object

A Ribs handle maps many-to-one with a Hibernate session. When there are no more Ribs handles left, the Hibernate session will be released too.

The methods in Handle is not to be used outside the framework in most cases, since they are internal, brittle, not based on Hibernate in all cases, and very much subject to change. Currently they provide capabilities that aren‘t part of the framework yet, such as migrations and setting up test data.

Methods

get   new   release  

Classes and Modules

Class Ribs::Handle::NotConnectedError

Attributes

db  [R]  The current database for this handle

Public Class methods

Returns a handle object from the database from. The available values for from is either one of the existing defined database names, or :default, which will give a handle to the default database.

[Source]

    # File lib/ribs/handle.rb, line 25
25:       def get(from = :default)
26:         db = case from
27:              when :default
28:                Ribs::DB::get
29:              when Ribs::DB
30:                from
31:              else
32:                Ribs::DB::get(from)
33:              end
34:         db.handle
35:       end

Creates a new handle that points to the provided db and hibernate_session

[Source]

    # File lib/ribs/handle.rb, line 44
44:     def initialize(db, hibernate_session)
45:       @db = db
46:       @connected = true
47:       @hibernate_session = hibernate_session
48:     end

Public Instance methods

Releases this handle from the database. This will possibly result in closing the internal Hibernate session, if this is the last Ribs session pointing to that Hibernate session.

[Source]

    # File lib/ribs/handle.rb, line 53
53:     def release
54:       chk_conn
55:       @connected = false
56:       @db.release(self)
57:     end

[Validate]