Class: RubyEventStore::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Stream

Returns a new instance of Stream.



5
6
7
8
# File 'lib/ruby_event_store/stream.rb', line 5

def initialize(name)
  raise IncorrectStreamData if !name.equal?(GLOBAL_STREAM) && (name.nil? || name.empty?)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/ruby_event_store/stream.rb', line 14

def name
  @name
end

Instance Method Details

#==(other_stream) ⇒ Object Also known as: eql?



20
21
22
# File 'lib/ruby_event_store/stream.rb', line 20

def ==(other_stream)
  other_stream.instance_of?(self.class) && other_stream.name.eql?(name)
end

#global?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/ruby_event_store/stream.rb', line 10

def global?
  name.equal?(GLOBAL_STREAM)
end

#hashObject



16
17
18
# File 'lib/ruby_event_store/stream.rb', line 16

def hash
  name.hash ^ self.class.hash
end