Sha256: 65672cc624034eddfcca3310959d8e773f005b252c0baf3807f1e51a3a6c6e52

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 Bytes

Contents

module Sufia
  module Collection
    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 to_param
      noid
    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

    module ClassMethods
      # override the default indexing service
      def indexer
        Sufia::IndexingService
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sufia-6.0.0.rc2 sufia-models/app/models/concerns/sufia/collection.rb
sufia-models-6.0.0.rc2 app/models/concerns/sufia/collection.rb
sufia-6.0.0.rc1 sufia-models/app/models/concerns/sufia/collection.rb
sufia-models-6.0.0.rc1 app/models/concerns/sufia/collection.rb