Sha256: c3a78b8dd9bd3e9e2d5415c38749e6e5c087ef1bd3b50a08821f85f11a350082

Contents?: true

Size: 566 Bytes

Versions: 4

Compression:

Stored size: 566 Bytes

Contents

module Sufia
  module CollectionBehavior
    extend ActiveSupport::Concern
    include Hydra::Collection
    include Sufia::ModelMethods
    include Sufia::Noid
    include Sufia::GenericFile::Permissions

    included do
      before_save :update_permissions
      validates :title, presence: true
    end

    def update_permissions
      self.visibility = "open"
    end

    # Compute the sum of each file in the collection
    # Return an integer of the result
    def bytes
      members.reduce(0) { |sum, gf| sum + gf.file_size.first.to_i }
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sufia-6.0.0.rc4 sufia-models/app/models/concerns/sufia/collection_behavior.rb
sufia-models-6.0.0.rc4 app/models/concerns/sufia/collection_behavior.rb
sufia-6.0.0.rc3 sufia-models/app/models/concerns/sufia/collection_behavior.rb
sufia-models-6.0.0.rc3 app/models/concerns/sufia/collection_behavior.rb