Class: RubyEventStore::Metadata
- Inherits:
-
Object
- Object
- RubyEventStore::Metadata
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/ruby_event_store/metadata.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, val) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(h = self) ⇒ Metadata
constructor
A new instance of Metadata.
Constructor Details
#initialize(h = self) ⇒ Metadata
Returns a new instance of Metadata.
12 13 14 15 16 17 |
# File 'lib/ruby_event_store/metadata.rb', line 12 def initialize(h = self) @h = {} h.each do |k, v| self[k] = (v) end end |
Instance Method Details
#[](key) ⇒ Object
19 20 21 22 |
# File 'lib/ruby_event_store/metadata.rb', line 19 def [](key) raise ArgumentError unless Symbol === key @h[key] end |
#[]=(key, val) ⇒ Object
24 25 26 27 28 |
# File 'lib/ruby_event_store/metadata.rb', line 24 def []=(key, val) raise ArgumentError unless allowed_types.any?{|klass| klass === val } raise ArgumentError unless Symbol === key @h[key]=val end |
#each(&block) ⇒ Object
30 31 32 |
# File 'lib/ruby_event_store/metadata.rb', line 30 def each(&block) @h.each(&block) end |