Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Maru.Entity

Elixir copy of grape-entity for serializing objects.

Usage:

defmodule PostEntity do
  use Maru.Entity

  expose :id
  expose :title
  expose :body, as: :content

  expose :disabled, if: fn(post, _options) -> post.is_disabled end
  expose :active, unless: fn(post, _options) -> post.is_disabled end
end

defmodule CommentEntity do
  use Maru.Entity

  expose :body
  expose :post, with: PostEntity, if: fn(comment, _options) -> comment.post != nil end
end

defmodule AuthorEntity do
  use Maru.Entity

  expose :name
  expose :posts, with: PostEntity

  expose :posts_count, [], fn(author, options) ->
    length(author.posts)
  end
end

About

Elixir clone of Grape::Entity

Resources

Packages

No packages published

Languages

You can’t perform that action at this time.