Class: Yoda::Store::Objects::PatchSet
- Inherits:
-
Object
- Object
- Yoda::Store::Objects::PatchSet
- Defined in:
- lib/yoda/store/objects/patch_set.rb
Overview
PatchSet manages patch updates and patch outdates. Besides, this class provides api to modify objects by using owning patches.
Defined Under Namespace
Classes: AddressIndex
Instance Method Summary collapse
- #delete(id) ⇒ Object
- #find(address) ⇒ Addressable?
- #has_key?(address) ⇒ true, false
-
#initialize ⇒ PatchSet
constructor
A new instance of PatchSet.
- #keys ⇒ Array<Symbol>
- #patch(object) ⇒ Addressable
- #register(patch) ⇒ void
Constructor Details
#initialize ⇒ PatchSet
Returns a new instance of PatchSet.
47 48 49 50 |
# File 'lib/yoda/store/objects/patch_set.rb', line 47 def initialize @patches = Hash.new @address_index = AddressIndex.new end |
Instance Method Details
#delete(id) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/yoda/store/objects/patch_set.rb', line 60 def delete(id) if patch = patches[id.to_sym] address_index.delete(patch) end patches.delete(id.to_sym) end |
#find(address) ⇒ Addressable?
76 77 78 79 80 81 82 |
# File 'lib/yoda/store/objects/patch_set.rb', line 76 def find(address) if (patches = get_patches(address)).empty? nil else Merger.new(patches).merged_instance end end |
#has_key?(address) ⇒ true, false
91 92 93 |
# File 'lib/yoda/store/objects/patch_set.rb', line 91 def has_key?(address) !address_index.get(address.to_sym).empty? end |
#keys ⇒ Array<Symbol>
85 86 87 |
# File 'lib/yoda/store/objects/patch_set.rb', line 85 def keys address_index.keys.to_a end |
#patch(object) ⇒ Addressable
69 70 71 72 |
# File 'lib/yoda/store/objects/patch_set.rb', line 69 def patch(object) objects_in_patch = get_patches(object.address) Merger.new([object, *objects_in_patch]).merged_instance end |
#register(patch) ⇒ void
This method returns an undefined value.
54 55 56 57 |
# File 'lib/yoda/store/objects/patch_set.rb', line 54 def register(patch) address_index.register(patch) patches[patch.id.to_sym] = patch end |