module QuickStore
Allows configuring a YAML store and accessing the configured YAML store through the .store method.
Constants
- VERSION
Attributes
configuration[RW]
Public Class Methods
config()
click to toggle source
Returns the QuickStore::Configuration
.
# File lib/quick_store.rb, line 26 def self.config self.configuration ||= Configuration.new end
configure() { |config| ... }
click to toggle source
Configures the QuickStore::Store
QuickStore.configure do |config| config.file_path = 'path/to/store/file.yml' config.key_separator = '|' # default is '/' end
# File lib/quick_store.rb, line 19 def self.configure yield(config) if block_given? raise FilePathNotConfiguredError unless config.file_path config end
store()
click to toggle source
Returns the QuickStore::Store
. You can store and receive data from the store using different methods:
# Using dynamic setters and getters QuickStore.store.arbitrary_key = 'value' # => "value" QuickStore.store.arbitrary_key # => "value" # Using the ::set and ::get methods QuickStore.store.set(:arbitrary_key, 'value') # => "value" QuickStore.store.get(:arbitrary_key) # => "value" # Example for a nested key ('/' is the default key separator) QuickStore.store.set('a/b/c', 'value') # => {"b"=>{"c"=>"value"}} QuickStore.store.get('a/b/c') # => "value" QuickStore.store.get('a/b') # => {"c"=>"value"} QuickStore.store.get('a') # => {"b"=>{"c"=>"value"}}
# File lib/quick_store.rb, line 46 def self.store QuickStore::Store end