Sha256: 1ebee70e21e55ff02cdaa315d7845c2f2b44bfb7c70fe209e92c5d8d69e11bf5

Contents?: true

Size: 1.38 KB

Versions: 23

Compression:

Stored size: 1.38 KB

Contents

module Naf
  class ApplicationSchedulePrerequisite < ::Naf::NafBase
    # Protect from mass-assignment issue
    attr_accessible :application_schedule_id,
                    :prerequisite_application_schedule_id

    #---------------------
    # *** Associations ***
    #+++++++++++++++++++++

    belongs_to :application_schedule,
      class_name: "::Naf::ApplicationSchedule"
    belongs_to :prerequisite_application_schedule,
      class_name: "::Naf::ApplicationSchedule"

    #--------------------
    # *** Validations ***
    #++++++++++++++++++++

    validates :prerequisite_application_schedule_id, presence: true
    validates :application_schedule_id, uniqueness: {
                                          scope: :prerequisite_application_schedule_id
                                        }

    def self.pickleables(pickler)
			return self.joins([application_schedule: :application]).
				where('applications.deleted = false').
				where(
					"NOT EXISTS(
					   SELECT
						   1
						 FROM
						   #{::Naf.schema_name}.application_schedules AS a_s
						 WHERE
						   application_schedule_prerequisites.prerequisite_application_schedule_id = a_s.id AND
						 EXISTS(
						   SELECT
							   1
							 FROM
							   #{::Naf.schema_name}.applications AS a
							 WHERE
							   a_s.application_id = a.id AND
								   deleted IS TRUE
						 )
					)"
				)
    end

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
naf-2.1.13 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.12 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.11 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.10 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.9 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.8 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.6 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.5 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.4 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.3 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.2 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.1 app/models/naf/application_schedule_prerequisite.rb
naf-2.1.0 app/models/naf/application_schedule_prerequisite.rb
naf-2.0.4 app/models/naf/application_schedule_prerequisite.rb
naf-2.0.3 app/models/naf/application_schedule_prerequisite.rb
naf-2.0.2 app/models/naf/application_schedule_prerequisite.rb
naf-2.0.1 app/models/naf/application_schedule_prerequisite.rb
naf-2.0.0 app/models/naf/application_schedule_prerequisite.rb
naf-1.1.4 app/models/naf/application_schedule_prerequisite.rb
naf-1.1.3 app/models/naf/application_schedule_prerequisite.rb