Class: Hyrax::VersioningService
- Inherits:
-
Object
- Object
- Hyrax::VersioningService
- Defined in:
- app/services/hyrax/versioning_service.rb
Class Method Summary collapse
-
.create(content, user = nil) ⇒ Object
Make a version and record the version committer.
- .latest_version_of(file) ⇒ Object
-
.record_committer(content, user_key) ⇒ Object
Record the version committer of the last version.
- .versioned_file_id(file) ⇒ Object
Class Method Details
.create(content, user = nil) ⇒ Object
Make a version and record the version committer
9 10 11 12 |
# File 'app/services/hyrax/versioning_service.rb', line 9 def create(content, user = nil) use_valkyrie = content.is_a? Hyrax::FileMetadata perform_create(content, user, use_valkyrie) end |
.latest_version_of(file) ⇒ Object
15 16 17 |
# File 'app/services/hyrax/versioning_service.rb', line 15 def latest_version_of(file) file.versions.last end |
.record_committer(content, user_key) ⇒ Object
Record the version committer of the last version
32 33 34 35 36 37 38 |
# File 'app/services/hyrax/versioning_service.rb', line 32 def record_committer(content, user_key) user_key = user_key.user_key if user_key.respond_to?(:user_key) version = latest_version_of(content) return if version.nil? version_id = content.is_a?(Hyrax::FileMetadata) ? version.id.to_s : version.uri Hyrax::VersionCommitter.create(version_id: version_id, committer_login: user_key) end |
.versioned_file_id(file) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/services/hyrax/versioning_service.rb', line 20 def versioned_file_id(file) versions = file.versions.all if versions.present? Hyrax.config.translate_uri_to_id.call(versions.last.uri) else file.id end end |