MapSchema.Examples.Employee (map_schema v0.2.6) View Source
Employee example
Link to this section Summary
Functions
Get contact_email value of string type.
Get name value of string type.
Get surname value of string type.
It´s will return true, if the map follow the schema.
Let decode json to Object. Checking every type following the schema.
Let decode json and mut a existing object . Checking every type following the schema.
Intenal it´s using the method put/2
.
Let encode object to Json.
mut the value of contact_email field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of name field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
mut the value of surname field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
This method only create a new simple map %{}. Yes.
Put a new value in each field of the update map, in the field of the object.
Put a new value in each field of the update map, in the field of the object.
Put a new value in contact_email field. Before of update the valor will be check it.
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
Put a new value in name field. Before of update the valor will be check it.
Put a new value in surname field. Before of update the valor will be check it.
The Schema is: %{contact: %{email: :string}, name: :string, surname: :string}
Get the module of type by name
Say if the schema use Atomize mode.
Map of types
Link to this section Functions
Get contact_email value of string type.
Get name value of string type.
Get surname value of string type.
It´s will return true, if the map follow the schema.
Let decode json to Object. Checking every type following the schema.
Note: This method use Jason library.
Specs
json_decode(mapa :: MapSchema.Examples.Employee, json :: BitString) :: Any
Let decode json and mut a existing object . Checking every type following the schema.
Intenal it´s using the method put/2
.
Note: This method use Jason library.
Parameters
- mapa: Object
- json: Json object
Let encode object to Json.
Note: This method use Jason library.
mut the value of contact_email field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that contact_email is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.mut_contact_email(fn(_old)-> "Santander" end)
iex> Elixir.MapSchema.Examples.Employee.get_contact_email(obj)
"Santander"
mut the value of name field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that name is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.mut_name(fn(_old)-> "Barcelona" end)
iex> Elixir.MapSchema.Examples.Employee.get_name(obj)
"Barcelona"
mut the value of surname field, using a mut_fn.(actualValue)
that will recive the actual value.
Before of update the valor will be check it.
Remember that surname is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.mut_surname(fn(_old)-> "Santiago" end)
iex> Elixir.MapSchema.Examples.Employee.get_surname(obj)
"Santiago"
This method only create a new simple map %{}. Yes.
Because the idea it´s the data structure will be independent of MapSchema but the module will have the schema that the maps should be follow.
Example:
iex>Elixir.MapSchema.Examples.Employee.new()
%{}
Put a new value in each field of the update map, in the field of the object.
But before of update the values always will be check the type.
If a field dont exist in the schema throw exception. (If you need be less strict you can use put_ifmatch/1
or put_ifmatch/2
)
Put a new value in each field of the update map, in the field of the object.
But before of update the values always will be check the type.
If a field dont exist in the schema throw exception. (If you need be less strict you can use put_ifmatch/1
or put_ifmatch/2
)
Put a new value in contact_email field. Before of update the valor will be check it.
Remember that contact_email is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.put_contact_email("Santiago")
iex> Elixir.MapSchema.Examples.Employee.get_contact_email(obj)
"Santiago"
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
But before of update the values always will be check the type.
Put a new value in each field of the update map, in the field of the object only if exist the field in the schema (ifmatch)
But before of update the values always will be check the type.
Put a new value in name field. Before of update the valor will be check it.
Remember that name is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.put_name("Santiago")
iex> Elixir.MapSchema.Examples.Employee.get_name(obj)
"Santiago"
Put a new value in surname field. Before of update the valor will be check it.
Remember that surname is string type.
Example:
iex>obj = Elixir.MapSchema.Examples.Employee.new()
...> |> Elixir.MapSchema.Examples.Employee.put_surname("Galicia")
iex> Elixir.MapSchema.Examples.Employee.get_surname(obj)
"Galicia"
The Schema is: %{contact: %{email: :string}, name: :string, surname: :string}
Get the module of type by name
Say if the schema use Atomize mode.
Map of types