Class: Intercom::Lib::FlatStore
- Inherits:
-
Hash
- Object
- Hash
- Intercom::Lib::FlatStore
- Defined in:
- lib/intercom/lib/flat_store.rb
Overview
Sub-class of Hash for storing custom data attributes. Doesn’t allow nested Hashes or Arrays. And requires String or Symbol keys.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(attributes = {}) ⇒ FlatStore
constructor
A new instance of FlatStore.
Constructor Details
#initialize(attributes = {}) ⇒ FlatStore
Returns a new instance of FlatStore.
8 9 10 11 12 13 |
# File 'lib/intercom/lib/flat_store.rb', line 8 def initialize(attributes={}) (attributes).each do |key, value| validate_key_and_value(key, value) self[key] = value end end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/intercom/lib/flat_store.rb', line 20 def [](key) super(key.to_s) end |
#[]=(key, value) ⇒ Object
15 16 17 18 |
# File 'lib/intercom/lib/flat_store.rb', line 15 def []=(key, value) validate_key_and_value(key, value) super(key.to_s, value) end |