Class: Vdb::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vdb/config.rb

Overview

Configuration for the vdb engine.

Examples:

Minimal setup (no auth)

Vdb.configure do |c|
  # no-op — just mounting the engine is enough
end

With basic auth and a custom extra schema

Vdb.configure do |c|
  c.username  = 'admin'
  c.password  = 'secret'
  c.databases = {
    'primary' => Rails.root.join('db', 'schema.rb'),
    'audit'   => Rails.root.join('db', 'audit_schema.rb')
  }
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



32
33
34
35
36
37
# File 'lib/vdb/config.rb', line 32

def initialize
  @username  = nil
  @password  = nil
  @databases = { 'primary' => nil } # nil = auto-resolve at request time
  @title     = 'Database ERD'
end

Instance Attribute Details

#databasesObject

Hash of label => Pathname/String path to the schema.rb file. Each entry becomes a tab in the ERD UI. Defaults to the host app’s primary schema.



27
28
29
# File 'lib/vdb/config.rb', line 27

def databases
  @databases
end

#passwordObject

HTTP Basic Auth credentials. Leave nil to disable auth entirely.



22
23
24
# File 'lib/vdb/config.rb', line 22

def password
  @password
end

#titleObject

Page title shown in the browser tab and header.



30
31
32
# File 'lib/vdb/config.rb', line 30

def title
  @title
end

#usernameObject

HTTP Basic Auth credentials. Leave nil to disable auth entirely.



22
23
24
# File 'lib/vdb/config.rb', line 22

def username
  @username
end