Sha256: e0fa7f54abf4882e12a50bd8e36086b841e87c7deb94a81c2a1c671786ec9ef3

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module Tramway::SportSchool
  class Document < ::Tramway::Core::ApplicationRecord
    mount_uploader :file, FileUploader

    enumerize :document_type, in: [ :education, :school_info, :provision, :headers, :finance ], default: :education

    state_machine :view_state, initial: :published do
      state :published
      state :hidden

      event :publish do
        transition hidden: :published
      end

      event :hide do
        transition published: :hidden
      end
    end

    scope :published, -> { where view_state: :published }
    scope :hidden, -> { where view_state: :hidden }

    scope :education, -> { where document_type: :education }
    scope :school_info, -> { where document_type: :school_info }
    scope :provision, -> { where document_type: :provision }
    scope :headers, -> { where document_type: :headers }
    scope :finance, -> { where document_type: :finance }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tramway-sport_school-1.1.3.1 app/models/tramway/sport_school/document.rb