Sha256: 932c9b083cd5fa872fe33423871f269ab87b58640469f16312ce254428208859
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
module Jobshop class Inspection::Result < ApplicationRecord FALSE_VALUES = [false, 0, "0", "f", "F", "false", "FALSE", "off", "OFF"] self.primary_keys = [ :organization_id, :report_id, :criterion_id, :criterion_type, :position ] belongs_to :organization belongs_to :report, class_name: "Jobshop::Inspection::Report", foreign_key: [ :organization_id, :report_id ] belongs_to :criterion, polymorphic: true, optional: true, dependent: :destroy, foreign_key: [ :organization_id, :report_id, :criterion_id, :criterion_type ] belongs_to :tuple, class_name: "Jobshop::Inspection::Tuple", foreign_key: [ :organization_id, :report_id, :position ] def value if self[:unit] == "boolean" !!self[:value] else # binding.pry self[:value] && Unitwise(self[:value].truncate(4), self[:unit]) end end def value=(value) if criterion.unit == "boolean" self[:value] = 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.157 | app/models/jobshop/inspection/result.rb |