Class: Observed::Hash::Builder
- Inherits:
-
Object
- Object
- Observed::Hash::Builder
- Includes:
- KeyPathEncoding
- Defined in:
- lib/observed/hash/builder.rb
Instance Method Summary collapse
- #[]=(key_path, value) ⇒ Object
- #build ⇒ Object
-
#initialize(defaults = {}) ⇒ Builder
constructor
A new instance of Builder.
Methods included from KeyPathEncoding
Constructor Details
#initialize(defaults = {}) ⇒ Builder
Returns a new instance of Builder.
8 9 10 |
# File 'lib/observed/hash/builder.rb', line 8 def initialize(defaults={}) @hash = defaults.dup end |
Instance Method Details
#[]=(key_path, value) ⇒ Object
12 13 14 15 16 |
# File 'lib/observed/hash/builder.rb', line 12 def []=(key_path, value) at_key_path_on_hash @hash, key_path, create_if_missing: true do |h, k| h[k] = value end end |
#build ⇒ Object
18 19 20 |
# File 'lib/observed/hash/builder.rb', line 18 def build @hash end |