Sha256: 2630ffbc4d5cd168f6c2b84b327224ba065e0c0c028cf9e776bdb4cf158e8967

Contents?: true

Size: 751 Bytes

Versions: 6

Compression:

Stored size: 751 Bytes

Contents

module ContentState
  class Published < Base
    include Reloadable
    include Singleton
    class << self
      def derivable_from(content)
        !content.new_record? && content.published
      end
    end

    def serialize_on(content)
      true
    end

    def published?
      true
    end

    def change_published_state(content, boolean)
      content[:published] = boolean
      if ! content.published
        content[:published_at] = nil
        content.state = Draft.instance
      end
    end

    def set_published_at(content, new_time)
      content[:published_at] = new_time
      return if content.published_at.nil?
      if content.published_at > Time.now
        content.state = JustPublished.instance
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typo-3.99.0 app/models/content_state/published.rb
typo-3.99.1 app/models/content_state/published.rb
typo-3.99.2 app/models/content_state/published.rb
typo-3.99.3 app/models/content_state/published.rb
typo-4.0.0 app/models/content_state/published.rb
typo-3.99.4 app/models/content_state/published.rb