1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-10 21:24:20 +01:00
fab-manager/app/models/footprintable.rb

43 lines
822 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# SuperClass for models that are secured by chained footprints.
class Footprintable < ApplicationRecord
self.abstract_class = true
def self.columns_out_of_footprint
[]
end
2021-04-16 16:03:10 +02:00
def footprint_children
[]
end
def sort_on_field
'id'
end
def check_footprint
2021-04-16 16:03:10 +02:00
footprint_children.map(&:check_footprint).all? && footprint == compute_footprint
end
2021-04-16 16:03:10 +02:00
def chain_record
self.footprint = compute_footprint
save!
FootprintDebug.create!(
footprint: footprint,
2021-04-16 16:03:10 +02:00
data: FootprintService.footprint_data(self.class, self),
klass: self.class.name
)
end
def debug_footprint
FootprintService.debug_footprint(self.class, self)
end
2021-06-09 18:48:51 +02:00
#protected
2021-04-16 16:03:10 +02:00
def compute_footprint
FootprintService.compute_footprint(self.class, self)
end
end