Sha256: aca895520eb48d23c3851294f85840168f810f4e6edb8d5c200c422074837ba8
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Cmor module Audits module ResourcesController module PaperTrailConcern extend ActiveSupport::Concern included do before_action(only: :versions) { load_resource; load_versions } before_action(only: :version) { load_resource; load_version } before_action(only: :version_at) { load_resource; load_version_by_timestamp } end def versions end def version end def version_at render :version end private def load_versions @versions = @resource.versions end def load_version @version = @resource.versions.find(params[:version_id]) @resource = @version&.reify || @resource end def load_version_by_timestamp timestamp = begin DateTime.parse(params[:version_at]) rescue TypeError Time.zone.now end @version = @resource.versions.subsequent(timestamp, true).first @resource = @version&.reify || @resource end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems