Sha256: 988df6d691d6a47005d4611d34e29b03eadcc4979b364399dbec23a39b0ffc36

Contents?: true

Size: 762 Bytes

Versions: 2

Compression:

Stored size: 762 Bytes

Contents

module ContentState
  class Published < Base
    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)
      if ! boolean
        content[:published] = false
        content[:published_at] = nil
        content.state = Factory.new(:just_withdrawn)
      end
    end

    def withdraw(content)
      content.state = Factory.new(:just_withdrawn)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.1.1 app/models/content_state/published.rb
typo-4.1 app/models/content_state/published.rb