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

Work with Maru.Type #8

Open
falood opened this issue Feb 7, 2017 · 3 comments
Open

Work with Maru.Type #8

falood opened this issue Feb 7, 2017 · 3 comments
Milestone

Comments

@falood
Copy link
Member

falood commented Feb 7, 2017

This is a feature for v0.3.x, will use a totally different DSL.
the type option is quite useful for generating documents.
custom Type can be defined like this:

defmodule Maru.Types.Date do
  use Maru.Type

  def arguments do
    [:format]
  end
  
  def serialize(output, %{format: "m/d/Y"}) do
    ...
  end
  
  def serialize(output, %{format: "Y-m-d"}) do
    ...
  end
end
expose :age, type: Integer

expose :name, type: fn(instance, _options) ->
  "#{instance.firstname} #{instance.lastname}"
end |> String

expose :image, type: fn(instance, _options) ->
  File.read!(instance.image_path)
end |> Base64

expose :data, type: Data, format: "m/d/Y"

expose :posts, type: List[PostEntity]
@falood falood added this to the v0.3 milestone Feb 7, 2017
@jalcine
Copy link

jalcine commented May 31, 2018

This looks like a very powerful feature. Has any progress (via a public branch) been made?

@falood
Copy link
Member Author

falood commented May 31, 2018

Thanks for reminding me, in the last year I have a lot of business things and took less time on open source projects, will try to take more time on them 🙂

@jalcine
Copy link

jalcine commented May 31, 2018

Totally! No rush

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

No branches or pull requests

2 participants