Module: Decidim::Publicable

Extended by:
ActiveSupport::Concern
Included in:
Component, ContentBlock
Defined in:
lib/decidim/publicable.rb

Overview

This concern contains the logic related to publication and promotion.

Instance Method Summary collapse

Instance Method Details

#previously_published?Boolean

Returns:

  • (Boolean)


49
# File 'lib/decidim/publicable.rb', line 49

def previously_published? = respond_to?(:versions) && versions.where(event: "update").where("object ->> 'published_at' IS NOT NULL").any?

#publish!Object

Public: Publishes this component

Returns true if the record was properly saved, false otherwise.



37
38
39
# File 'lib/decidim/publicable.rb', line 37

def publish!
  update!(published_at: Time.current)
end

#published?Boolean

Public: Checks whether the record has been published or not.

Returns true if published, false otherwise.

Returns:

  • (Boolean)


29
30
31
# File 'lib/decidim/publicable.rb', line 29

def published?
  published_at.present?
end

#unpublish!Object

Public: Unpublishes this component

Returns true if the record was properly saved, false otherwise.



45
46
47
# File 'lib/decidim/publicable.rb', line 45

def unpublish!
  update!(published_at: nil)
end