Sha256: 10b670483e2080078b54a1da422fa3bdf74055e79d03822b9dca4ba8ce1a60b2

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

require 'fiona7/binary_files_cleaner'

module Fiona7
  class ComplexObject
    include Fiona7::BinaryFilesCleaner

    def initialize(obj)
      @obj = obj
    end

    def widgets
      # TODO: optimize this through attr_values
      links = @obj[:X_widget_pool] || []
      WriteObj.where(obj_id: links.map {|l| l.destination_object_id }).to_a.to_set
    end

    def binaries
      referenced = []
      type_definition = Fiona7::TypeRegister.instance.read_mangled(@obj.obj_class)
      type_definition.attrs.each do |attribute|
        if attribute.type == :binary && attribute.real_name != "blob"
          (@obj[attribute.real_name] || []).each do |link|
            referenced << link.destination_object
            Rails.logger.debug("referenced #{referenced}")
          end
        end
      end
      referenced
    end

    def check_binaries
       binaries.each do |binary|
         unrelease_unused(binary)
       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/complex_object.rb