Sha256: 71485805d563cf05107fa4d99a5b81447f19b98ab638d1fac09f3929447e19ef
Contents?: true
Size: 1.06 KB
Versions: 28
Compression:
Stored size: 1.06 KB
Contents
require_dependency "renalware/accesses" module Renalware module Accesses class Plan < ApplicationRecord include Accountable belongs_to :patient, touch: true belongs_to :plan_type belongs_to :decided_by, class_name: "User", foreign_key: "decided_by_id" validates :plan_type, presence: true validates :decided_by, presence: true scope :ordered, -> { order(created_at: :desc) } scope :current, -> { where(terminated_at: nil) } scope :historical, -> { where.not(terminated_at: nil) } def self.policy_class BasePolicy end def self.attributes_to_ignore_when_comparing [:id, :created_at, :updated_at, :created_by_id, :updated_by_id] end def identical_to?(other) attrs_to_ignore = self.class.attributes_to_ignore_when_comparing.map(&:to_s) attributes.except(*attrs_to_ignore) == other.attributes.except(*attrs_to_ignore) end def terminate_by(user) self.terminated_at = Time.zone.now self.by = user save! end end end end
Version data entries
28 entries across 28 versions & 1 rubygems