Sha256: abc564395a8931fb197dca159d3f2bdd8e11c98e14c8f0f3614824cd22b7d4d6
Contents?: true
Size: 567 Bytes
Versions: 6
Compression:
Stored size: 567 Bytes
Contents
require "test_helper" require "ostruct" require "pp" source = OpenStruct.new(name: "30 Years Live", songs: [ OpenStruct.new(id: 1, title: "Dear Beloved"), OpenStruct.new(id: 2, title: "Fuck Armageddon")]) require "representable/object" class AlbumRepresenter < Representable::Decorator include Representable::Object property :name collection :songs, instance: ->(fragment, *) { Song.new } do property :title end end Album = Struct.new(:name, :songs) Song = Struct.new(:title) target = Album.new AlbumRepresenter.new(target).from_object(source)
Version data entries
6 entries across 6 versions & 3 rubygems