module Decidim::Publicable

This concern contains the logic related to publication and promotion.

Public Instance Methods

publish!() click to toggle source

Public: Publishes this component

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

# File lib/decidim/publicable.rb, line 37
def publish!
  update!(published_at: Time.current)
end
published() click to toggle source

Public: Scope to return only published records.

Returns an ActiveRecord::Relation.

# File lib/decidim/publicable.rb, line 14
def published
  where.not(published_at: nil)
end
published?() click to toggle source

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

Returns true if published, false otherwise.

# File lib/decidim/publicable.rb, line 29
def published?
  published_at.present?
end
unpublish!() click to toggle source

Public: Unpublishes this component

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

# File lib/decidim/publicable.rb, line 45
def unpublish!
  update!(published_at: nil)
end
unpublished() click to toggle source

Public: Scope to return only unpublished records.

Returns an ActiveRecord::Relation.

# File lib/decidim/publicable.rb, line 21
def unpublished
  where(published_at: nil)
end