Noizu.Entity.Field.Behaviour behaviour (NoizuLabs Entities v0.2.1)

Defines Entity.Field behavior used for marshalling from/to peristence layers and managing complex/compound types that compose/break fields up into layer specific fields.

Summary

Types

Field Entry Name

Field settings

Callbacks

Generate ecto generator field entries for given field. Used by Mix.Tasks.Nz.Gen.Entity

Return empty entity stub.

After Delete Hook for Entity Field Types. Runs at entity (not persistence layer) level. Update dependent entries/tables. (may span multiple storage types).

Before Create Hook for Entity Field Type. Runs at entity (not layer level).

Before Update Hook for Entity Field Types. Runs at entity (not persistence layer) level. Update dependent entries/tables. (may span multiple storage types).

Convert Type to Entity - Struct stored in entity may be incomplete, for example if real time data is bound. Runs at entity level, fully populates and possibly casts field to type used for persistence.

Types

field_name()

@type field_name() :: atom()

Field Entry Name

field_settings()

@type field_settings() :: Noizu.Entity.Meta.Field.field_settings()

Field settings

Callbacks

ecto_gen_string(name)

@callback ecto_gen_string(name :: field_name()) :: {:ok, any()} | {:error, any()}

Generate ecto generator field entries for given field. Used by Mix.Tasks.Nz.Gen.Entity

stub()

@callback stub() :: {:ok, any()} | {:error, any()}

Return empty entity stub.

type__after_delete(entity, settings, context, options)

@callback type__after_delete(
  entity :: any(),
  settings :: any(),
  context :: any(),
  options :: any()
) ::
  {:ok, any()} | {:error, any()}

After Delete Hook for Entity Field Types. Runs at entity (not persistence layer) level. Update dependent entries/tables. (may span multiple storage types).

type__before_create(entity, settings, context, options)

@callback type__before_create(
  entity :: any(),
  settings :: any(),
  context :: any(),
  options :: any()
) ::
  {:ok, any()} | {:error, any()}

Before Create Hook for Entity Field Type. Runs at entity (not layer level).

  • Populate entity if stub entry added(e.g. string to versioned string)
  • Persist dependent entities.

type__before_update(entity, settings, context, options)

@callback type__before_update(
  entity :: any(),
  settings :: any(),
  context :: any(),
  options :: any()
) ::
  {:ok, any()} | {:error, any()}

Before Update Hook for Entity Field Types. Runs at entity (not persistence layer) level. Update dependent entries/tables. (may span multiple storage types).

type_as_entity(entity, context, options)

@callback type_as_entity(entity :: any(), context :: any(), options :: any()) ::
  {:ok, any()} | {:error, any()}

Convert Type to Entity - Struct stored in entity may be incomplete, for example if real time data is bound. Runs at entity level, fully populates and possibly casts field to type used for persistence.