defmodule RecycledCloud.OpenNebula.Schema.Records do @moduledoc """ Here we define XSD template into something we can play with (Records). Records are not usually used in elixir except for integrating with erlang code - which is what we're doing right now: the records are defined in .hrl (erlang headers) by erlsom. See RecycledCloud.OpenNebula.Schema module for details. """ require Record alias RecycledCloud.OpenNebula.Schema @models %{ "vm" => Schema.generate_model_for("vm"), "vm_pool" => Schema.generate_model_for("vm_pool") } def get_model_for(object), do: Map.get(@models, object) for {name, record} <- Record.extract_all(from: Schema.get_hrl_for("vm")) do Record.defrecord name, record end Record.defrecord :VM_POOL, Record.extract(:VM_POOL, from: Schema.get_hrl_for("vm_pool")) end