Sha256: 03308f073256f3b1b4e26e87be03627b8744b3f37a485e8ae757cec3e7518a0a

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Fiona7
  module WidgetGc
    module SweepStrategies
      # This garbage collection strategy deletes working versions
      # of garbage widget objects
      # Its usefulness is limited to objects which hasn't been released yet
      # or gained links in working version
      #
      # This strategy should be only used
      # after deleting widgets
      class RevertSweep
        def initialize(object, widget_resolver)
          self.object = object
          self.widget_resolver = widget_resolver
        end

        def sweep!(garbage)
          garbage.each do |widget_object_id|
            # TODO: improve performance here
            widget_object = self.widget_resolver.all.find {|w| w.id == widget_object_id }
            revert!(widget_object)
          end
        end

        protected
        attr_accessor :object, :widget_resolver
        def revert!(widget_object)
          widget_object.take! if widget_object.really_edited?
          widget_object.revert! if widget_object.really_edited?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/widget_gc/sweep_strategies/revert_sweep.rb