Module: Ecoportal::API::Common::Content::CollectionModel::Model::Lookup

Extended by:
Includer
Defined in:
lib/ecoportal/api/common/content/collection_model/model/lookup.rb

Instance Method Summary collapse

Methods included from Includer

include_missing

Instance Method Details

#[](value) ⇒ Object

Get an element usign the key.

Parameters:

Returns:

  • (Object)

    the items_class element object



24
25
26
# File 'lib/ecoportal/api/common/content/collection_model/model/lookup.rb', line 24

def [](value)
  items_by_key[get_key(value)]
end

#include?(value) ⇒ Boolean

Checks if an element exists in the collection

Parameters:

Returns:

  • (Boolean)

    whether or not it is included



31
32
33
# File 'lib/ecoportal/api/common/content/collection_model/model/lookup.rb', line 31

def include?(value)
  items_by_key.key?(get_key(value))
end

#values_at(*keys) ⇒ Array<Object>

Returns the items_class element object.

Returns:

  • (Array<Object>)

    the items_class element object



36
37
38
# File 'lib/ecoportal/api/common/content/collection_model/model/lookup.rb', line 36

def values_at(*keys)
  keys.map {|key| self[key]}
end