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 |
# 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
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
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 |