Sha256: 805a5d529d5d9b953ca300d849213c7e2bdb00b36730fe77144e2ccfca96e6a5

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

module ContentState
  class Published < Base
    include Reloadable
    include Singleton

    def published?(content)
      true
    end

    def enter_hook(content)
      super
      content[:published] = true
      content[:published_at] ||= Time.now
    end

    def change_published_state(content, boolean)
      content[:published] = boolean
      if ! content.published
        content[:published_at] = nil
        content.state = Factory.new(:withdrawn)
      end
    end

    def withdraw(content)
      content.state = Factory.new(:withdrawn)
    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

3 entries across 3 versions & 1 rubygems

Version Path
typo-4.0.1 app/models/content_state/published.rb
typo-4.0.2 app/models/content_state/published.rb
typo-4.0.3 app/models/content_state/published.rb