Class: RubyEventStore::Metadata

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/ruby_event_store/metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(h = self) ⇒ Metadata

Returns a new instance of Metadata.



12
13
14
15
# File 'lib/ruby_event_store/metadata.rb', line 12

def initialize(h = self)
  @h = {}
  h.each { |k, v| self[k] = (v) }
end

Instance Method Details

#[](key) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
# File 'lib/ruby_event_store/metadata.rb', line 17

def [](key)
  raise ArgumentError unless Symbol === key
  @h[key]
end

#[]=(key, val) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'lib/ruby_event_store/metadata.rb', line 22

def []=(key, val)
  raise ArgumentError unless allowed_types.any? { |klass| klass === val }
  raise ArgumentError unless Symbol === key
  @h[key] = val
end

#each(&block) ⇒ Object



28
29
30
# File 'lib/ruby_event_store/metadata.rb', line 28

def each(&block)
  @h.each(&block)
end