Class: Lode::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lode/client.rb

Overview

Provides an enhanced PStore-based client.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, configuration: Configuration.new) {|configuration| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (configuration)


17
18
19
20
21
22
23
# File 'lib/lode/client.rb', line 17

def initialize path, configuration: Configuration.new
  yield configuration if block_given?

  @path = Pathname(path).make_ancestors
  @configuration = configuration
  @store = configuration.store_for path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



13
14
15
# File 'lib/lode/client.rb', line 13

def path
  @path
end

#storeObject (readonly)

Returns the value of attribute store.



13
14
15
# File 'lib/lode/client.rb', line 13

def store
  @store
end

Instance Method Details

#commit(key) ⇒ Object



29
30
31
32
33
34
# File 'lib/lode/client.rb', line 29

def commit(key, &)
  warn "`#{self.class}##{__method__}` is deprecated, use `#write` instead.",
       category: :deprecated

  write(key, &)
end

#read(key) ⇒ Object



25
# File 'lib/lode/client.rb', line 25

def read(key, &) = transact(__method__, key, &)

#write(key) ⇒ Object



27
# File 'lib/lode/client.rb', line 27

def write(key, &) = transact(:commit, key, &)