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

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/representable-3.2.0/test/examples/object.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/representable-3.2.0/test/examples/object.rb
representable-3.2.0 test/examples/object.rb
representable-3.1.1 test/examples/object.rb
representable-3.1.0 test/examples/object.rb
representable-3.0.4 test/examples/object.rb