class Yoda::Store::Objects::PatchSet
PatchSet
manages patch updates and patch outdates. Besides, this class provides api to modify objects by using owning patches.
Attributes
address_index[R]
@return [AddressIndex]
patches[R]
@return [{ Symbol => Patch
}]
Public Class Methods
new()
click to toggle source
# File lib/yoda/store/objects/patch_set.rb, line 47 def initialize @patches = Hash.new @address_index = AddressIndex.new end
Public Instance Methods
delete(id)
click to toggle source
@param id [String, Symbol]
# 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)
click to toggle source
@param address [String, Symbol] @return [Addressable, nil]
# 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)
click to toggle source
@param address [String, Symbol] @return [true, false]
# File lib/yoda/store/objects/patch_set.rb, line 91 def has_key?(address) !address_index.get(address.to_sym).empty? end
keys()
click to toggle source
@return [Array<Symbol>]
# File lib/yoda/store/objects/patch_set.rb, line 85 def keys address_index.keys.to_a end
patch(object)
click to toggle source
@param object [Addressable] @return [Addressable]
# 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)
click to toggle source
@param patch [Patch] @return [void]
# File lib/yoda/store/objects/patch_set.rb, line 54 def register(patch) address_index.register(patch) patches[patch.id.to_sym] = patch end
Private Instance Methods
get_patches(address)
click to toggle source
@param address [String, Symbol] @return [Array<Patch>]
# File lib/yoda/store/objects/patch_set.rb, line 105 def get_patches(address) patch_ids = address_index.get(address.to_sym) patch_ids.map { |id| patches[id].find(address.to_sym) } end