recurly v0.1.0 Recurly.XML.Schema
Module responsible for handling schemas of the resources. Schemas are used for building the resource structs as well as marshalling and unmarshalling the xml. The syntax for defining schemas is similar to Ecto:
defmodule MyResource do
use Recurly.XML.Schema
schema :my_resource do
field :a_string, :string
field :an_integer, :integer
field :a_float, :float, read_only: true
end
end
Calling use Recurly.XML.Schema
adds two macros, schema
and field
. It also defines
two functions on the module:
__resource_name__/0
__schema__/0
The first returns the name of the resource :my_schema
.
The second returns the fields and their options.
It also calls defstruct
passing in the names of the fields to definte the type.