Sha256: e3eb9c184b0af740b0e814eaeafc4b8f782b90af89e843c7cee1b7d3e7a3cda4
Contents?: true
Size: 1.23 KB
Versions: 4
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' require 'rom/memory' describe 'Using in-memory gateways for cross-repo access' do let(:configuration) do ROM::Configuration.new(left: :memory, right: :memory, main: :memory).use(:macros) end let(:container) { ROM.container(configuration) } let(:gateways) { container.gateways } it 'works' do configuration.relation(:users, gateway: :left) do def by_name(name) restrict(name: name) end end configuration.relation(:tasks, gateway: :right) configuration.relation(:users_and_tasks, gateway: :main) do def by_user(name) join(users.by_name(name), tasks) end end configuration.mappers do define(:users_and_tasks) do group tasks: [:title] end end gateways[:left][:users] << { user_id: 1, name: 'Joe' } gateways[:left][:users] << { user_id: 2, name: 'Jane' } gateways[:right][:tasks] << { user_id: 1, title: 'Have fun' } gateways[:right][:tasks] << { user_id: 2, title: 'Have fun' } user_and_tasks = container.relation(:users_and_tasks) .by_user('Jane') .as(:users_and_tasks) expect(user_and_tasks).to match_array([ { user_id: 2, name: 'Jane', tasks: [{ title: 'Have fun' }] } ]) end end
Version data entries
4 entries across 4 versions & 1 rubygems