exocci v0.1.0 OCCI.Model.Infrastructure.Compute View Source

Link to this section Summary

Functions

Return all categories attribute definition must be searched for

(Implements Access callback)

Get the attribute from entity, returning default value if not present

Invoked in order to access the value under key and update it at the same time

Invoked to “pop” the value under key out of the given data structure

Return required attribute keys

Link to this section Functions

Return all categories attribute definition must be searched for.

[ mixin0 mixin0 deps mixin1 mixin1 deps … kind kind parents ]

(Implements Access callback)

Returns:

  • :error -> key does not exists or value is not set and no default value
  • {:ok, nil} -> key exists but value is not set (and no default value)
  • {:ok, value} -> key exists and value is set (or there is a default value)
Link to this function get(entity, key, default \\ nil) View Source

Get the attribute from entity, returning default value if not present

Link to this function get_and_update(entity, key, fun) View Source

Invoked in order to access the value under key and update it at the same time.

The implementation of this callback should invoke fun with the value under key in the passed structure data, or with nil if key is not present in it. This function must return either {get_value, update_value} or :pop.

If the passed function returns {get_value, update_value}, the return value of this callback should be {get_value, new_data}, where:

  • get_value is the retrieved value (which can be operated on before being returned)
  • update_value is the new value to be stored under key
  • new_data is data after updating the value of key with update_value.

If the passed function returns :pop, the return value of this callback must be {value, new_data} where value is the value under key (or nil if not present) and new_data is data without key.

See the implementations of Map.get_and_update/3 or Keyword.get_and_update/3 for more examples.

Callback implementation for Access.get_and_update/3.

Link to this function new(attributes, mixins \\ [], model \\ OCCI.Model.Core) View Source

Creates a new entity of the kind

Invoked to “pop” the value under key out of the given data structure.

When key exists in the given structure data, the implementation should return a {value, new_data} tuple where value is the value that was under key and new_data is term without key.

When key is not present in the given structure, a tuple {value, data} should be returned, where value is implementation-defined.

See the implementations for Map.pop/3 or Keyword.pop/3 for more examples.

Callback implementation for Access.pop/2.

Return required attribute keys