Module: Decidim::Publicable

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 'decidim-core/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 'decidim-core/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 'decidim-core/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 'decidim-core/lib/decidim/publicable.rb', line 45

def unpublish!
  update!(published_at: nil)
end