Skip to content

Instantly share code, notes, and snippets.

@solnic
Last active February 24, 2017 16:40
Show Gist options
  • Save solnic/804b0389456182baf5fbe53051d25db6 to your computer and use it in GitHub Desktop.
Save solnic/804b0389456182baf5fbe53051d25db6 to your computer and use it in GitHub Desktop.
require 'rom'
require 'rom-repository'
rom = ROM.container(:sql, 'sqlite::memory') do |c|
c.default.create_table(:users) do
primary_key :id
column :name, String
end
c.default.create_table(:tasks) do
primary_key :id
foreign_key :user_id, :users
column :title, String
end
end
my_relations = ROM::RelationRegistry.new do |r, h|
h[:tasks] = rom.relations[:tasks]
end
my_container = ROM::Container.new(rom.gateways, my_relations, {}, {})
puts my_container.inspect
class MyRepo < ROM::Repository
relations :tasks
end
repo = MyRepo.new(my_container)
puts repo.relations.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment