lib/ecoportal/api/common/content/array_model.rb in ecoportal-api-v2-0.8.30 vs lib/ecoportal/api/common/content/array_model.rb in ecoportal-api-v2-0.8.31

- old
+ new

@@ -4,11 +4,11 @@ module Content # Class to handle a plain Array embedded in a Hashed model. # @note # - Its purpose is to handle an Array of basic objects (i.e. `Date`, `String`, `Number`) class ArrayModel < Content::DoubleModel - class TypeMismatchedComparison < Exception + class TypeMismatchedComparison < StandardError def initialize (this: nil, that: msg = "Trying to compare objects with different behavior.") if this msg += " From object with 'order_matters: #{this.order_matters?}' and 'uniq: #{this.uniq?}'." end if that @@ -28,11 +28,12 @@ # @return [Boolean] `true` if both elements have same behaviour def same_type?(a, b) raise "To use this comparison both objects should be `ArrayModel`" unless a.is_a?(ArrayModel) && b.is_a?(ArrayModel) (a.order_matters? == b.order_matters?) && (a.uniq? == b.uniq?) end - end + + inheritable_class_vars :order_matteres, :uniq def initialize(doc = [], parent: self, key: nil) super(doc, parent: parent, key: key) end