Sha256: 9ec0fcfa6929ef1b926472591768ebef72dc76049c69c1e30af2ee2a4c8a15f6

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

module ContentState
  class Draft < Base
    include Reloadable
    include Singleton

    def enter_hook(content)
      super
      content[:published] = false
      content.published_at = nil
    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

3 entries across 3 versions & 1 rubygems

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