Sha256: 2cb4cfae502dc7b7cc4211314fee0a748e555e6bbb6498aa38ba9ca6558b3bc5

Contents?: true

Size: 821 Bytes

Versions: 1

Compression:

Stored size: 821 Bytes

Contents

# encoding: utf-8

module PagesCore
  module PageModel
    module Status
      extend ActiveSupport::Concern

      module ClassMethods
        def status_labels
          {
            0 => "Draft",
            1 => "Reviewed",
            2 => "Published",
            3 => "Hidden",
            4 => "Deleted"
          }
        end
      end

      # Return the status of the page as a string
      def status_label
        self.class.status_labels[status]
      end

      def flag_as_deleted!
        update(status: 4)
      end

      def draft?
        status == 0
      end

      def reviewed?
        status == 1
      end

      def published?
        status == 2 && !autopublish?
      end

      def hidden?
        status == 3
      end

      def deleted?
        status == 4
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.5.1 app/models/concerns/pages_core/page_model/status.rb