Module: HistoryBook

Defined in:
lib/history_book.rb,
lib/history_book/event.rb,
lib/history_book/stream.rb,
lib/history_book/version.rb,
lib/history_book/memory/store.rb,
lib/history_book/sequel/store.rb,
lib/history_book/memory/configuration.rb,
lib/history_book/sequel/configuration.rb

Defined Under Namespace

Modules: Memory, Sequel Classes: Event, Stream

Constant Summary collapse

VERSION =
'0.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



12
13
14
# File 'lib/history_book.rb', line 12

def config
  @config
end

Class Method Details

._load_driver(driver) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/history_book.rb', line 32

def self._load_driver(driver)
  path = "history_book/#{driver}/configuration"
  require path
  path.classify.constantize
rescue LoadError
  raise "Unable to load #{driver} driver for history_book"
end

.configure(driver) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/history_book.rb', line 15

def self.configure(driver)
  driver_klass = _load_driver(driver)

  unless @config.instance_of?(driver_klass)
    @config = driver_klass.new
  end

  if block_given?
    yield @config
  end
end

.open(id) {|HistoryBook::Stream.new(id, store)| ... } ⇒ Object

Yields:



27
28
29
30
# File 'lib/history_book.rb', line 27

def self.open(id)
  store = config.create_store
  yield HistoryBook::Stream.new(id, store)
end