Module: PaperTrailScrapbook::VersionHelpers Private
- Included in:
- Changes, Chapter, JournalEntry
- Defined in:
- lib/paper_trail_scrapbook/version_helpers.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Module VersionHelpers provides methods for extracting common information from a version or PaperTrailScrapbook config
Instance Method Summary collapse
- #changes ⇒ Object private
- #config ⇒ Object private
- #create? ⇒ Boolean private
- #destroy? ⇒ Boolean private
- #kind ⇒ Object private
- #model ⇒ Object private
- #model_id ⇒ Object private
- #whenn ⇒ Object private
- #who ⇒ Object private
- #whodunnit_class ⇒ Object private
- #whodunnit_instance(author) ⇒ Object private
Instance Method Details
#changes ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 25 def changes Changes.new(version).change_log end |
#config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 29 def config PaperTrailScrapbook.config end |
#create? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 17 def create? event.eql?('create') end |
#destroy? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 21 def destroy? event.eql?('destroy') end |
#kind ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 37 def kind config.events[event] || raise(ArgumentError, "incorrect event:#{event}") end |
#model ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 9 def model version.item_type end |
#model_id ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 13 def model_id version.item_id end |
#whenn ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 33 def whenn version.created_at.strftime(config.time_format) end |
#who ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 42 def who = version. return config.unknown_whodunnit unless return unless whodunnit_class whodunnit_instance() end |
#whodunnit_class ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 50 def whodunnit_class config.whodunnit_class end |
#whodunnit_instance(author) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/paper_trail_scrapbook/version_helpers.rb', line 54 def whodunnit_instance() instance = begin whodunnit_class.find() rescue StandardError config.invalid_whodunnit.call() end return instance.to_whodunnit if instance.respond_to?(:to_whodunnit) instance.to_s end |