Sha256: a79f6b33864e914db83acec63fae70b915df82961c715bd414a0195adc392c6e
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
require "test_helper" class DeserializePipelineTest < MiniTest::Spec Album = Struct.new(:artist, :songs) Artist = Struct.new(:email) Song = Struct.new(:title) # tests [Collect[Instance, Prepare, Deserialize], Setter] class Representer < Representable::Decorator include Representable::Hash # property :artist, populator: Uber::Options::Value.new(ArtistPopulator.new), pass_options:true do # property :email # end # DISCUSS: rename to populator_pipeline ? collection :songs, parse_pipeline: ->(*) { [Collect[Instance, Prepare, Deserialize], Setter] }, instance: :instance!, exec_context: :decorator, pass_options: true do property :title end def instance!(*options) puts "@@@@@ #{options.inspect}" Song.new end def songs=(array) represented.songs=array end end it do skip "TODO: implement :parse_pipeline and :render_pipeline, and before/after/replace semantics" album = Album.new Representer.new(album).from_hash({"artist"=>{"email"=>"yo"}, "songs"=>[{"title"=>"Affliction"}, {"title"=>"Dream Beater"}]}) album.songs.must_equal([Song.new("Affliction"), Song.new("Dream Beater")]) puts album.inspect end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
representable-2.4.0.rc3 | test/---deserialize-pipeline_test.rb |
representable-2.4.0.rc2 | test/---deserialize-pipeline_test.rb |
representable-2.4.0.rc1 | test/---deserialize-pipeline_test.rb |