Class: Lode::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/lode/configuration.rb

Overview

Models the default configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store: PStore, mode: :default, table: Tables::Dictionary, primary_key: PRIMARY_KEY, registry: {}) ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
# File 'lib/lode/configuration.rb', line 11

def initialize store: PStore,
               mode: :default,
               table: Tables::Dictionary,
               primary_key: PRIMARY_KEY,
               registry: {}
  super
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of mode



7
8
9
# File 'lib/lode/configuration.rb', line 7

def mode
  @mode
end

#primary_keyObject

Returns the value of attribute primary_key

Returns:

  • (Object)

    the current value of primary_key



7
8
9
# File 'lib/lode/configuration.rb', line 7

def primary_key
  @primary_key
end

#registryObject

Returns the value of attribute registry

Returns:

  • (Object)

    the current value of registry



7
8
9
# File 'lib/lode/configuration.rb', line 7

def registry
  @registry
end

#storeObject

Returns the value of attribute store

Returns:

  • (Object)

    the current value of store



7
8
9
# File 'lib/lode/configuration.rb', line 7

def store
  @store
end

#tableObject

Returns the value of attribute table

Returns:

  • (Object)

    the current value of table



7
8
9
# File 'lib/lode/configuration.rb', line 7

def table
  @table
end

Instance Method Details

#register(key, model: Hash, primary_key: PRIMARY_KEY) ⇒ Object



25
26
27
28
# File 'lib/lode/configuration.rb', line 25

def register key, model: Hash, primary_key: PRIMARY_KEY
  registry[key] = Setting[model:, primary_key:]
  self
end

#store_for(path) ⇒ Object



19
# File 'lib/lode/configuration.rb', line 19

def store_for(path) = store.with(path, mode:)

#table_for(store, key, setting: Setting.new) ⇒ Object



21
22
23
# File 'lib/lode/configuration.rb', line 21

def table_for store, key, setting: Setting.new
  table.new store, key, setting: registry.fetch(key, setting)
end