Skip to content

Commit

Permalink
Nobody likes a .x.0 release anyway...
Browse files Browse the repository at this point in the history
  • Loading branch information
karmajunkie committed May 26, 2014
1 parent 6ba0a7d commit da9e3fd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/replay/backends.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def clear
end

def published(envelope)
@store[stream_id] ||= []
@store[stream_id] << envelope
@store[envelope.stream_id] ||= []
@store[envelope.stream_id] << envelope
end

def event_stream(stream_id)
Expand Down
4 changes: 2 additions & 2 deletions lib/replay/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def repository_load(klass_or_instance, stream_id, options={})
raise Errors::EventStreamNotFoundError.new("Could not find any events for stream identifier #{stream_id}") if options[:create].nil?
end

obj = klass_or_instance.is_a?(Class) ? prepare(klass.new, options[:metadata]) : klass_or_instance
obj = klass_or_instance.is_a?(Class) ? prepare(klass_or_instance.new, options[:metadata]) : klass_or_instance
obj.create(stream_id) if options[:create] && stream.empty?
obj.apply(stream.map(&:event))

Expand All @@ -41,7 +41,7 @@ def self.refresh(obj)
end

def prepare(obj, metadata={})
obj.subscription_manager = SubscriptionManager.new(configuration.logger, metadata)
obj.subscription_manager = SubscriptionManager.new(configuration.logger, metadata || {})
@configuration.subscribers.each do |subscriber|
obj.add_subscriber(subscriber)
end
Expand Down
6 changes: 6 additions & 0 deletions lib/replay/repository/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Replay
module Repository
class Configuration
attr_accessor :logger
attr_writer :reject_load_on_empty_stream
def initialize(logger = nil)
@default_subscribers =[]
@logger = logger
Expand All @@ -28,6 +29,11 @@ def store=(store)
add_default_subscriber(@store)
end

def reject_load_on_empty_stream?
@reject_load_on_empty_stream ||= true
@reject_load_on_empty_stream
end

def store
@store
end
Expand Down
2 changes: 1 addition & 1 deletion lib/replay/subscription_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def add_subscriber(subscriber)
def notify_subscribers(stream_id, event, metadata = {})
@subscribers.each do |sub|
begin
meta = metadata.merge(@session_metadata)
meta = metadata.merge(@session_metadata || {})
sub.published(EventEnvelope.new(stream_id, event, meta))
#sub.published(stream_id, event, metadata)
rescue Exception => e
Expand Down

0 comments on commit da9e3fd

Please sign in to comment.