Sha256: 01c2415350454b1f83e7e9ffa7fb23da17180c80d8b8e67a877f4f9c6572d83e

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

module Jobshop
  class Inspection::Criterion < ApplicationRecord
    self.primary_keys = [ :organization_id, :report_id, :criterion_id, :criterion_type ]

    after_create do
      self.class.connection.clear_query_cache
      @attributes = self.class.unscoped {
        self.class.find_by!(organization: organization, criterion_id: criterion_id)
      }.instance_variable_get(:@attributes)
      @new_record = false
      self
    end

    belongs_to :organization
    belongs_to :criterion, polymorphic: true, optional: true, dependent: :destroy,
      foreign_key: [ :organization_id, :report_id, :criterion_id, :criterion_type ]
    belongs_to :report, class_name: "Jobshop::Inspection::Report",
      foreign_key: [ :organization_id, :report_id ], inverse_of: :criteria

    delegate :ascii, :pass?, :random, :unit, to: :criterion
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jobshop-0.0.157 app/models/jobshop/inspection/criterion.rb