Class: Replay::Repository::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/replay/repository/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger = nil) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
8
# File 'lib/replay/repository/configuration.rb', line 5

def initialize(logger = nil)
  @default_subscribers =[]
  @logger = logger
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/replay/repository/configuration.rb', line 4

def logger
  @logger
end

Class Method Details

.defaultObject



10
11
12
# File 'lib/replay/repository/configuration.rb', line 10

def self.default
  self.new(Replay.logger)
end

Instance Method Details

#add_default_subscriber(subscriber) ⇒ Object



14
15
16
17
# File 'lib/replay/repository/configuration.rb', line 14

def add_default_subscriber(subscriber)
  subscriber = Replay::Backends.resolve(subscriber) if subscriber.is_a?(String) || subscriber.is_a?(Symbol)
  @default_subscribers << subscriber
end

#storeObject



31
32
33
# File 'lib/replay/repository/configuration.rb', line 31

def store
  @store
end

#store=(store) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/replay/repository/configuration.rb', line 23

def store=(store)
  store = Replay::Backends.resolve(store)
  raise Replay::InvalidStorageError.new(store) unless store.respond_to?(:event_stream)
  raise Replay::InvalidSubscriberError.new(store) unless store.respond_to?(:published)
  @store = store
  add_default_subscriber(@store)
end

#subscribersObject



19
20
21
# File 'lib/replay/repository/configuration.rb', line 19

def subscribers
  @default_subscribers
end