Sha256: 9f6e3eeacad41ef44893e58304af1515e9dca781a8c9638dd88ea40293d74ea2

Contents?: true

Size: 834 Bytes

Versions: 28

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

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.zero?
      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

28 entries across 28 versions & 1 rubygems

Version Path
pages_core-3.15.4 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.15.3 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.15.2 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.15.1 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.14.0 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.13.0 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.7 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.6 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.5 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.4 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.3 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.2 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.1 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.12.0 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.11.3 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.11.2 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.11.1 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.11.0 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.10.2 app/models/concerns/pages_core/page_model/status.rb
pages_core-3.10.1 app/models/concerns/pages_core/page_model/status.rb