Class: Alf::Rest::Config
- Inherits:
-
Support::Config
- Object
- Support::Config
- Alf::Rest::Config
- Defined in:
- lib/alf/rest/config.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
The current database connection.
Instance Method Summary collapse
-
#connect(&bl) ⇒ Object
Yields the block with the database connection.
-
#database=(db) ⇒ Object
Sets the database, coercing it if required.
-
#reconnect(opts) ⇒ Object
Reconnect.
-
#viewpoint ⇒ Object
Returns the default viewpoint to use.
-
#viewpoint=(vp) ⇒ Object
Sets the default viewpoint on connection options.
Instance Attribute Details
#connection ⇒ Object (readonly)
The current database connection
18 19 20 |
# File 'lib/alf/rest/config.rb', line 18 def connection @connection end |
Instance Method Details
#connect(&bl) ⇒ Object
Yields the block with the database connection
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/alf/rest/config.rb', line 21 def connect(&bl) return yield unless database database.connect() do |conn| @connection = conn if transactional? conn.in_transaction{ yield(conn) } else yield(conn) end end end |
#database=(db) ⇒ Object
Sets the database, coercing it if required
39 40 41 |
# File 'lib/alf/rest/config.rb', line 39 def database=(db) @database = db.is_a?(Database) ? db : Alf.database(db) end |
#reconnect(opts) ⇒ Object
Reconnect
34 35 36 |
# File 'lib/alf/rest/config.rb', line 34 def reconnect(opts) connection.reconnect(opts) end |
#viewpoint ⇒ Object
Returns the default viewpoint to use
44 45 46 |
# File 'lib/alf/rest/config.rb', line 44 def viewpoint [:viewpoint] end |
#viewpoint=(vp) ⇒ Object
Sets the default viewpoint on connection options
49 50 51 |
# File 'lib/alf/rest/config.rb', line 49 def viewpoint=(vp) [:viewpoint] = vp end |