Sha256: 3ac28b9ed5889d725057ed0e19c1e985e5ec5d3650f3282911f288f7b25f05cc
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literals: true module Jobshop class Inspection::Result < ApplicationRecord FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"] self.primary_keys = %i[ organization_id report_id criterion_id criterion_type position ] belongs_to :organization belongs_to :report, class_name: "Jobshop::Inspection::Report", foreign_key: %i[ organization_id report_id ] belongs_to :criterion, polymorphic: true, optional: true, dependent: :destroy, foreign_key: %i[ organization_id report_id criterion_id criterion_type ] belongs_to :tuple, class_name: "Jobshop::Inspection::Tuple", foreign_key: %i[ organization_id report_id position ] def value if self[:unit] == "boolean" FALSE_VALUES.exclude?(self[:value]) else self[:value] && Unitwise(self[:value].truncate(4), self[:unit]) end end def value=(value) if criterion.unit == "boolean" self[:value] = FALSE_VALUES.exclude?(value) self[:unit] = "boolean" else if value.respond_to?(:unit) self[:value] = value.value self[:unit] = value.unit else self[:value] = value end end end def in_spec? criterion.pass?(self[:value]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jobshop-0.0.167 | app/models/jobshop/inspection/result.rb |