Module: Ecoportal::API::Common::Content::DoubleModel::DoubleDoc::RootedKey

Extended by:
Includer
Defined in:
lib/ecoportal/api/common/content/double_model/double_doc/rooted_key.rb

Instance Method Summary collapse

Methods included from Includer

include_missing

Instance Method Details

#_rooted_doc_key(value) ⇒ Object

Note:

this method was introduced with CollectionModel. The individual elements/items wouldn't know how to fetch their own model via their parent. This required to introduce _rooted_doc_key in all DoubleModel ancestors. It just delegates up the resolution of a value key.

Note:

this method can't be protected. It might be accessed by cousing classes. parent class to a child class. See last line of this method.

Offers a method for child classes to transform the key, provided that the child's doc can be accessed.

Parameters:

  • value (Content::DoubleModel, Array<String>, String)
    • String or Array<String>: is mirrored.
    • DoubleModel and root?: is mirrored.
    • non root? DoubleModel: deletages to _parent


33
34
35
36
37
38
39
40
# File 'lib/ecoportal/api/common/content/double_model/double_doc/rooted_key.rb', line 33

def _rooted_doc_key(value)
  #print "!(#{value}<=#{self.class})" if value.is_a?(Content::DoubleModel) && !value.root?
  return value unless value.is_a?(Content::DoubleModel)
  return value if value.root?

  #print "?(#{value.class}<=#{value._parent.class})"
  value._parent._rooted_doc_key(value)
end