app/presenters/error_message/detail.rb
module ErrorMessage
class Detail
include Comparable
attr_reader :attribute, :long_message, :short_message, :api_message
def initialize(attribute, long_message, short_message, api_message, sequence = 99_999)
@attribute = attribute
@long_message = long_message
@short_message = short_message
@api_message = api_message
@sequence = sequence
end
def sequence
@sequence || 99_999
end
def ==(other)
return false unless other.is_a?(self.class)
@attribute == other.attribute &&
@long_message == other.long_message &&
@short_message == other.short_message &&
@api_message == other.api_message
end
def <=>(other)
sequence <=> other.sequence
end
def to_summary_error
[attribute, long_message]
end
# rubocop:disable Rails/OutputSafety
def long_message_link
%(<a href="##{@attribute}">#{@long_message}</a>).html_safe
end
# rubocop:enable Rails/OutputSafety
end
end