29 lines
484 B
Ruby
Raw Permalink Normal View History

module Tables
class Table < Array
attr_writer :discomfort
attr_reader :id
def initialize(*args)
super
reset
@id = SecureRandom.uuid
end
def reset
original_discomfort = @discomfort
@discomfort = nil
original_discomfort
end
def discomfort
@discomfort ||= DiscomfortCalculator.new(self).calculate
end
def dup
super.tap do |new_table|
new_table.discomfort = nil
end
end
end
end