Class: Renalware::Accesses::Plan

Inherits:
ApplicationRecord show all
Includes:
Renalware::Accountable
Defined in:
app/models/renalware/accesses/plan.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Renalware::Accountable

#first_or_create_by!, #save_by, #save_by!, #update_by

Class Method Details

.attributes_to_ignore_when_comparingObject



25
26
27
# File 'app/models/renalware/accesses/plan.rb', line 25

def self.attributes_to_ignore_when_comparing
  [:id, :created_at, :updated_at, :created_by_id, :updated_by_id]
end

.policy_classObject



21
22
23
# File 'app/models/renalware/accesses/plan.rb', line 21

def self.policy_class
  BasePolicy
end

Instance Method Details

#identical_to?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'app/models/renalware/accesses/plan.rb', line 29

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

#terminate_by(user) ⇒ Object



34
35
36
37
38
# File 'app/models/renalware/accesses/plan.rb', line 34

def terminate_by(user)
  self.terminated_at = Time.zone.now
  self.by = user
  save!
end