Sha256: 3a7a36ff12b5397566420da18ece64b5b1c2e56442ccf9ea4402a18d16dc3116

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

module Fiona7
  module WidgetGc
    module SweepStrategies
      # This garbage collection strategy deletes BOTH working
      # and released versions of garbage widget objects
      # This effecively nukes the widget object.
      # NOTE: It normally requires permissionRoot
      # on all garbage widget objects. But since it is meant
      # to be used during release process, which only requires
      # permissionWrite permission elevation is used
      #
      # This strategy should be only used shortly
      # before releasing the page
      class ArchiveSweep
        def initialize(object, widget_resolver)
          self.object = object
          self.widget_resolver = widget_resolver
        end

        def sweep!(garbage)
          # NOTE: this emulates permission elevation:
          # permissionWrite -> permissionRoot
          return unless self.object.permission.write?

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

        protected
        attr_accessor :object, :widget_resolver
        def archive!(widget_object)
          Reactor::Sudo.su(Fiona7.root) do
            widget_object.send(:crul_obj).remove_active_contents!
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.6.1.1.1 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/widget_gc/sweep_strategies/archive_sweep.rb