lib/ecoportal/api/common/content/double_model.rb in ecoportal-api-v2-2.0.6 vs lib/ecoportal/api/common/content/double_model.rb in ecoportal-api-v2-2.0.7

- old
+ new

@@ -3,11 +3,11 @@ module Common module Content # Basic model class, to **build _get_ / _set_ `methods`** for a given property # which differs of `attr_*` ruby native class methods because `pass*` # completelly **links** the methods **to a subjacent `Hash` model** - class DoubleModel < Common::BaseModel + class DoubleModel < Ecoportal::API::Common::BaseModel class UnlinkedModel < StandardError def initialize(msg = "Something went wrong when linking the document.", from: nil, key: nil) msg += " From: #{from}." if from msg += " key: #{key}." if key super(msg) @@ -15,13 +15,13 @@ end class NoKeyMethod < StandardError end - NOT_USED = Common::Content::ClassHelpers::NOT_USED - extend Common::Content::ClassHelpers - include Common::Content::ModelHelpers + NOT_USED = ClassHelpers::NOT_USED + extend ClassHelpers + include ModelHelpers class << self attr_reader :key def key? @@ -174,11 +174,11 @@ def passarray(*methods, order_matters: true, uniq: true) methods.each do |method| method = method.to_s.freeze var = instance_variable_name(method) - dim_class = new_class(method, inherits: Common::Content::ArrayModel) do |klass| + dim_class = new_class(method, inherits: ArrayModel) do |klass| klass.order_matters = order_matters klass.uniq = uniq end define_method method do @@ -211,11 +211,11 @@ def embeds_many(method, key: method, klass: nil, enum_class: nil, order_matters: false, order_key: nil, read_only: read_only?) if enum_class eclass = enum_class elsif klass - eclass = new_class("#{method}::#{klass}", inherits: Common::Content::CollectionModel) do |dim_class| + eclass = new_class("#{method}::#{klass}", inherits: CollectionModel) do |dim_class| # NOTE: new_class may resolve the namespace of the class to an already existing class dim_class.klass ||= klass dim_class.order_matters = order_matters dim_class.order_key = order_key dim_class.read_only! if read_only @@ -376,11 +376,11 @@ # @return [nil, Hash] the patch `Hash` model including only the changes between # `original_doc` and `doc` def as_update new_doc = as_json - Common::Content::HashDiffPatch.patch_diff(new_doc, original_doc) + HashDiffPatch.patch_diff(new_doc, original_doc) end # @return [Boolean] stating if there are changes def dirty? au = as_update @@ -507,10 +507,10 @@ end # It allows to work-around missing item_key def setup_items_key(embedded_class, obj_doc) # only if is going to be a collection - return unless obj_doc.is_a?(Array) && embedded_class < Common::Content::CollectionModel + return unless obj_doc.is_a?(Array) && embedded_class < CollectionModel return unless (item_class = embedded_class.klass) # if already has key don't need to work around return if item_class&.key # apply work around