Sha256: e3d2d8c63abf67da26692c86b6be16ac85690d4953221ded3058c2d2753b59f8
Contents?: true
Size: 784 Bytes
Versions: 12
Compression:
Stored size: 784 Bytes
Contents
require 'spec_helper' require 'rom/memory' describe 'Mappers / Prefixing attributes' do let(:setup) { ROM.setup(:memory) } before do setup.relation(:users) end it 'automatically maps all attributes using the provided prefix' do class Test::UserMapper < ROM::Mapper relation :users prefix :user model name: 'Test::User' attribute :id attribute :name attribute :email end rom = setup.finalize Test::User.send(:include, Equalizer.new(:id, :name, :email)) rom.relations.users << { user_id: 123, user_name: 'Jane', user_email: 'jane@doe.org' } jane = rom.relation(:users).as(:users).first expect(jane).to eql(Test::User.new(id: 123, name: 'Jane', email: 'jane@doe.org')) end end
Version data entries
12 entries across 12 versions & 1 rubygems