All Downloads are FREE. Search and download functionalities are using the official Maven repository.

elixir.model.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
{{>licenseInfo}}
{{#models}}{{#model}}defmodule {{moduleName}}.Model.{{classname}} do
  @moduledoc """
  {{description}}
  """

  @derive [Poison.Encoder]
  defstruct [
    {{#vars}}:"{{baseName}}"{{#hasMore}},
    {{/hasMore}}{{/vars}}
  ]

  @type t :: %__MODULE__{
    {{#vars}}:"{{baseName}}" => {{{dataType}}}{{#hasMore}},
    {{/hasMore}}{{/vars}}
  }
end

defimpl Poison.Decoder, for: {{moduleName}}.Model.{{classname}} do
{{#hasComplexVars}}
  import {{moduleName}}.Deserializer
  def decode(value, options) do
    value
    {{#vars}}
    {{^isPrimitiveType}}
    {{#datatype}}|> deserialize(:"{{baseName}}", {{#isListContainer}}:list, {{moduleName}}.Model.{{items.datatype}}{{/isListContainer}}{{#isMapContainer}}:map, {{moduleName}}.Model.{{items.datatype}}{{/isMapContainer}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMapContainer}}{{^isListContainer}}:struct, {{moduleName}}.Model.{{dataType}}{{/isListContainer}}{{/isMapContainer}}{{/isDateTime}}{{/isDate}}, options)
    {{/datatype}}
    {{/isPrimitiveType}}
    {{/vars}}
{{/hasComplexVars}}
{{^hasComplexVars}}
  def decode(value, _options) do
    value
{{/hasComplexVars}}
  end
end
{{/model}}{{/models}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy