lib/ddr/models/attached_files_profile.rb in ddr-models-3.0.0.rc4 vs lib/ddr/models/attached_files_profile.rb in ddr-models-3.0.0.rc5
- old
+ new
@@ -1,25 +1,26 @@
module Ddr::Models
class AttachedFilesProfile
include ActiveModel::Serializers::JSON
- attr_reader :files_hash
+ attr_reader :object
- # @param files_hash [ActiveFedora::FilesHash]
- def initialize(files_hash)
- @files_hash = files_hash
+ def initialize(object)
+ @object = object
end
def attributes
- files_hash.keys.each_with_object({}) do |key, memo|
- unless files_hash[key].destroyed?
- memo[key.to_s] = nil
- end
- end
+ files.keys.map { |k| [k, nil] }.to_h
end
def read_attribute_for_serialization(key)
- AttachedFileProfile.new(files_hash[key])
+ AttachedFileProfile.new(files[key])
+ end
+
+ private
+
+ def files
+ object.attached_files_having_content
end
end
end