Class: Yoda::Store::Objects::Patch
- Inherits:
-
Object
- Object
- Yoda::Store::Objects::Patch
- Defined in:
- lib/yoda/store/objects/patch.rb
Defined Under Namespace
Classes: ParentModifier
Instance Attribute Summary collapse
- #id ⇒ Object readonly
- #registry ⇒ Object readonly
Instance Method Summary collapse
- #find(address) ⇒ Addressable? (also: #get)
- #has_key?(address) ⇒ true, false
-
#initialize(id, contents = nil) ⇒ Patch
constructor
A new instance of Patch.
- #keys ⇒ Array<Symbol>
- #register(addressable) ⇒ void
Constructor Details
#initialize(id, contents = nil) ⇒ Patch
Returns a new instance of Patch.
13 14 15 16 |
# File 'lib/yoda/store/objects/patch.rb', line 13 def initialize(id, contents = nil) @id = id @registry = (contents || []).map { |content| [content.address.to_sym, content] }.to_h end |
Instance Attribute Details
#id ⇒ Object (readonly)
6 7 8 |
# File 'lib/yoda/store/objects/patch.rb', line 6 def id @id end |
#registry ⇒ Object (readonly)
9 10 11 |
# File 'lib/yoda/store/objects/patch.rb', line 9 def registry @registry end |
Instance Method Details
#find(address) ⇒ Addressable? Also known as: get
20 21 22 |
# File 'lib/yoda/store/objects/patch.rb', line 20 def find(address, **) @registry[address.to_sym] end |
#has_key?(address) ⇒ true, false
27 28 29 |
# File 'lib/yoda/store/objects/patch.rb', line 27 def has_key?(address) @registry.has_key?(address.to_sym) end |
#keys ⇒ Array<Symbol>
32 33 34 |
# File 'lib/yoda/store/objects/patch.rb', line 32 def keys @registry.keys end |
#register(addressable) ⇒ void
This method returns an undefined value.
38 39 40 41 42 43 44 45 46 |
# File 'lib/yoda/store/objects/patch.rb', line 38 def register(addressable) parent_modifier.add_address_to_parent(addressable) if el = @registry[addressable.address.to_sym] @registry[addressable.address.to_sym] = el.merge(addressable) else @registry[addressable.address.to_sym] = addressable end end |