Sha256: 7a9cc10c3d5c390fcceefed450510a5ce74abeeeaaa9c8bc35b91634c8aaa754
Contents?: true
Size: 589 Bytes
Versions: 22
Compression:
Stored size: 589 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")]) pp source 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) pp target
Version data entries
22 entries across 18 versions & 1 rubygems