lkn-core v0.4.3 Lkn.Core.Map View Source
A specialized module to easily implement Map, one of the two kind of Entities used by lkn.
This module provides the defmap/2
macro, to easily define a module which
implements the Lkn.Core.Entity
behaviour module.
Defining a new map is pretty easy, at it can be seen as some kind of key-value
store. First, the @components
annotation has to be used to define the set of
components the map can be abstracted away with. Then, the
Lkn.Core.Entity.init_properties/1
behaviour function needs to be
implemented.
Finally, the defmap/2
macro user needs to implement a start_link
functions, that is only a proxy to Lkn.Core.Entity.start_link/3
; the last
argument being the arguments for init_properties
.
Here is an example of a proper use of defmap/2
.
defmap Test.Map do
@components [Test.Map.Component1, Test.Map.Component2]
def start_link(key, args) do
Lkn.Core.Entity.start_link(__MODULE__, key, args)
end
def init_properties(args) do
# ...
end
end
Link to this section Summary
Functions
An helper macro to define a Map module
Link to this section Types
A key to identify and reach a Map.
Link to this section Functions
An helper macro to define a Map module.
The main idea of this macro is to hide the boilerplate required to define a
Map. Its counterpartLkn.Core.Puppet.defpuppet/2
can be used to define a
Puppet.