Sha256: c0b6f381659bb009410f68ddc792b9ffc2e47157f46d2511375809f784e2c5e9
Contents?: true
Size: 605 Bytes
Versions: 60
Compression:
Stored size: 605 Bytes
Contents
module Concerns module Publishable extend ActiveSupport::Concern included do scope :published, ->{ where('published_at < ?', Time.zone.now).order('published_at DESC') } scope :not_published, ->{ where('published_at > ? OR published_at IS NULL OR published_at = ?', Time.zone.now, '') } end def publish!(time = Time.zone.now) update_attribute :published_at, time end def unpublish! update_attribute :published_at, nil end def published? published_at && published_at.past? end def unpublished? !published? end end end
Version data entries
60 entries across 60 versions & 1 rubygems