Sha256: 1621a586a6d36a1eeaf44c383fd5bdc2d998f05202d2c2306ddfa7eeafaaf058
Contents?: true
Size: 861 Bytes
Versions: 6
Compression:
Stored size: 861 Bytes
Contents
module ContentState class Draft < Base include Reloadable include Singleton class << self def derivable_from(content) ! content.new_record? && ! content.published && content.published_at.nil? end end def serialize_on(content) content[:published] = false content.published_at = nil true end def change_published_state(content, boolean) content[:published] = boolean if content.published content.state = JustPublished.instance end end def set_published_at(content, new_time) content[:published_at] = new_time return if new_time.nil? if new_time <= Time.now content[:published_at] = nil else content.state = PublicationPending.instance end end def draft? true end end end
Version data entries
6 entries across 6 versions & 1 rubygems