Module: Shared::HasPapertrail

Extended by:
ActiveSupport::Concern
Included in:
AssertedDistribution, CollectingEvent, CollectionObject, Content, ControlledVocabularyTerm, FieldOccurrence, GeographicItem, Loan, Namespace, Otu, Person, PreparationType, Repository, Sequence, Serial, Source, TaxonName
Defined in:
app/models/concerns/shared/has_papertrail.rb

Overview

Shared code for models using PaperTrail

Instance Method Summary collapse

Instance Method Details

#attribute_updated(attribute) ⇒ :updated_by_id, ...

Returns:

  • (:updated_by_id, attribute, nil)


27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/concerns/shared/has_papertrail.rb', line 27

def attribute_updated(attribute)
   versions.reverse.each do |v|
    r = v.reify
    unless r.nil?
      if a = r.send(attribute)
        return r.updated_at
      end
    end
  end
 nil
end

#attribute_updater(attribute) ⇒ :updated_by_id, ...

Returns:

  • (:updated_by_id, attribute, nil)


14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/concerns/shared/has_papertrail.rb', line 14

def attribute_updater(attribute)
  versions.reverse.each do |v|
    r = v.reify
    unless r.nil?
      if a = r.send(attribute)
        return r.updated_by_id
      end
    end
  end
  nil
end