Sha256: df0b3b2eb9741f92a2e1b91ba87841e4ce2dd233950948550ab185eb9d1b258e
Contents?: true
Size: 1.25 KB
Versions: 5
Compression:
Stored size: 1.25 KB
Contents
require 'fin/indexed_list' module Fin # Represents IndexedList that tracks its own changes (dirty-tracking), # and updates (series of changes resulting in a consistent state) class ChangedList < IndexedList # Changed attribute is set automatically, whenever item is actually added # or deleted from list (please note, change may leave data in inconsistent state!) attr_accessor :changed # Number of changes (successful item additions or removals) attr_accessor :change_count # Updated attribute should be set EXTERNALLY - only when data update # transaction is completed, and list data is known to be consistent # (e.g., when onStreamDataEnd event fires for DataStream) attr_accessor :updated def initialize @updated = true @changed = true @change_count = 0 super end def add? item if super @changed = true # Mark List as changed @change_count += 1 item end end def remove? item if super @changed = true # Mark List as changed @change_count += 1 item end end # Observers inform list that it's recent changes are reflected def update_noted @updated = false @changed = false end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
fin-0.1.6 | lib/fin/changed_list.rb |
fin-0.1.5 | lib/fin/changed_list.rb |
fin-0.1.4 | lib/fin/changed_list.rb |
fin-0.1.3 | lib/fin/changed_list.rb |
fin-0.1.2 | lib/fin/changed_list.rb |