Module: Leda::Store

Included in:
Leda::Stores::Elasticsearch, Leda::Stores::Postgresql
Defined in:
lib/leda/store.rb

Overview

Mix-in for defining the set of data needed from a particular backing store in a data unit. E.g., for a relational database it might be a set of tables.

A store must define the following methods:

# Dump the configured data to the specified directory
# @param [Pathname]
def dump(directory); end

# Restore from the data found in the given directory
# @param [Pathname]
def restore_from(directory); end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/leda/store.rb', line 19

def options
  @options
end

Class Method Details

.default_name(clazz) ⇒ Object



29
30
31
# File 'lib/leda/store.rb', line 29

def self.default_name(clazz)
  clazz.name.demodulize.underscore
end

.find(store_name) ⇒ Object



45
46
47
# File 'lib/leda/store.rb', line 45

def self.find(store_name)
  registered_stores[store_name.to_s]
end

.included(included_into) ⇒ Object



37
38
39
# File 'lib/leda/store.rb', line 37

def self.included(included_into)
  register_store(included_into, default_name(included_into))
end

.register_store(store_class, name) ⇒ Object



41
42
43
# File 'lib/leda/store.rb', line 41

def self.register_store(store_class, name)
  registered_stores[name.to_s] = store_class
end

.registered_storesObject



33
34
35
# File 'lib/leda/store.rb', line 33

def self.registered_stores
  @registered_stores ||= {}
end

Instance Method Details

#initialize(options = {}) ⇒ Object



21
22
23
# File 'lib/leda/store.rb', line 21

def initialize(options={})
  @options = options.dup
end

#nameObject



25
26
27
# File 'lib/leda/store.rb', line 25

def name
  Store.default_name(self.class)
end