-
-
Save PavelPenkov/f8c4fa6b089ad61f79ec35b844a89396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User = Struct.new(:email) | |
Post = Struct.new(:user, :text) | |
class PostRepresenter < Representable::Decorator | |
include Representable::JSON | |
property :text | |
property :user, populator: lambda { |input, options| options[:represented].user = User.new } | |
end | |
p = Post.new | |
PostRepresenter.new(p).from_hash({ "text" => "my text"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment