Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend our intermediate format to include meta. #4

Open
mtwilliams opened this issue May 13, 2016 · 1 comment
Open

Extend our intermediate format to include meta. #4

mtwilliams opened this issue May 13, 2016 · 1 comment
Assignees
Labels
Milestone

Comments

@mtwilliams
Copy link
Owner

Given something like,

defmodule Person do
  defstruct ~w(name)a
end

defmodule PersonSerializer do
  use Blazon.Serializable
  field name, :string
  field gender, enum: [type: :gender, ~w(male female)a], via: fn (person) ->
    if String.contains?("John")
      :male
    else
      :female
    end
  end
end

We should produce an intermediate form like so:

iex(1)> Blazon.intermediate([PersonSerializer], [%Person{name: "John Doe"}, %Person{name: "Jane Doe"}])
{[[{:name, [type: :string], "John Doe"},
   {:gender, [type: {:enum, [name: :gender], [:male, :female]}], :male}],
  [{:name, [type: :string], "Jane Doe"},
   {:gender, [type: {:enum, [name: :gender], [:male, :female]}], :female}],
 [type: [People]]}

This will allow more structured serializers i.e. xml to provide proper type semantics.

@mtwilliams mtwilliams self-assigned this May 13, 2016
@mtwilliams mtwilliams added this to the 1.0 milestone May 13, 2016
@mtwilliams
Copy link
Owner Author

I'm thinking a 3-arity tuple of the form {field, [attributes], generator} would make the most sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant