Class: Burner::Data
- Inherits:
-
Object
- Object
- Burner::Data
- Extended by:
- Forwardable
- Defined in:
- lib/burner/data.rb
Overview
Defines a key value pair data store per our library. It is basically a composite object around a hash with indifferent key typing.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(hash = {}) ⇒ Data
constructor
A new instance of Data.
- #to_h ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Data
Returns a new instance of Data.
18 19 20 21 22 |
# File 'lib/burner/data.rb', line 18 def initialize(hash = {}) @internal_hash = {} (hash || {}).each { |k, v| self[k] = v } end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
36 37 38 39 |
# File 'lib/burner/data.rb', line 36 def ==(other) other.instance_of?(self.class) && to_h == other.to_h end |
#[](key) ⇒ Object
28 29 30 |
# File 'lib/burner/data.rb', line 28 def [](key) internal_hash[key.to_s] end |
#[]=(key, value) ⇒ Object
24 25 26 |
# File 'lib/burner/data.rb', line 24 def []=(key, value) internal_hash[key.to_s] = value end |
#to_h ⇒ Object
32 33 34 |
# File 'lib/burner/data.rb', line 32 def to_h internal_hash end |