Class: Alf::Rest::Config

Inherits:
Support::Config
  • Object
show all
Defined in:
lib/alf/rest/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject (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(connection_options) 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

#viewpointObject

Returns the default viewpoint to use



44
45
46
# File 'lib/alf/rest/config.rb', line 44

def viewpoint
  connection_options[: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)
  connection_options[:viewpoint] = vp
end