Module: ActiveAdmin::Annotations::ContentRevision
- Defined in:
- lib/activeadmin/annotations/content_revision.rb
Class Method Summary collapse
- .content_subject_for(subject, version) ⇒ Object
- .current_version_for(subject) ⇒ Object
- .enabled_for?(subject) ⇒ Boolean
- .stale_context_message(review:) ⇒ Object
- .stale_review_message(review:, pinned_version:, latest_version:) ⇒ Object
- .version_label(version) ⇒ Object
Class Method Details
.content_subject_for(subject, version) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 27 def content_subject_for(subject, version) if custom_content_subject return custom_content_subject.call(subject, version.to_i) end if active_version_subject?(subject) return active_version_content_subject(subject, version.to_i) end subject end |
.current_version_for(subject) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 17 def current_version_for(subject) if custom_current_version return custom_current_version.call(subject).to_i end return subject.current_version.to_i if active_version_subject?(subject) 0 end |
.enabled_for?(subject) ⇒ Boolean
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 6 def enabled_for?(subject) case ActiveAdmin::Annotations.content_revision_strategy when false, :none false when true, :active_version active_version_subject?(subject) || custom_version_resolver? else custom_version_resolver? || active_version_subject?(subject) end end |
.stale_context_message(review:) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 50 def (review:) = ActiveAdmin::Annotations. return if .blank? return .call(review) if .respond_to?(:call) .to_s end |
.stale_review_message(review:, pinned_version:, latest_version:) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 39 def (review:, pinned_version:, latest_version:) = ActiveAdmin::Annotations. return if .blank? if .respond_to?(:call) return .call(review, pinned_version:, latest_version:) end format(.to_s, pinned_version:, latest_version:) end |
.version_label(version) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/activeadmin/annotations/content_revision.rb', line 59 def version_label(version) label = ActiveAdmin::Annotations.content_revision_label return if label == false if label.respond_to?(:call) return label.call(version.to_i) end format((label || "Content version %{version}").to_s, version: version.to_i) end |