lib/ecoportal/api/common/content/collection_model.rb in ecoportal-api-v2-0.8.13 vs lib/ecoportal/api/common/content/collection_model.rb in ecoportal-api-v2-0.8.14
- old
+ new
@@ -107,10 +107,14 @@
# @return [Class] the class of the elements of the Collection
def items_class
self.class.klass
end
+ def _doc_pos(value)
+ _doc_key(value)
+ end
+
# Transforms `value` into the actual `key` to access the object in the doc `Array`
# @note
# - The name of the method is after the paren't class method
# - This method would have been better called `_doc_pos` :)
def _doc_key(value)
@@ -148,9 +152,16 @@
# Get an element usign the `key`.
# @param value [String, Hash, Ecoportal::API::Common::Content::DoubleModel]
# @return [Object] the `items_class` element object
def [](value)
items_by_key[get_key(value)]
+ end
+
+ # Checks if an element exists in the collection
+ # @param value [String, Hash, Ecoportal::API::Common::Content::DoubleModel]
+ # @return [Boolean] whether or not it is included
+ def include?(value)
+ items_by_key.key?(get_key(value))
end
# @return [Array<Object>] the `items_class` element object
def values_at(*keys)
keys.map {|key| self[key]}