class ROM::Repository::Root
A specialized repository type dedicated to work with a root relation
This repository type builds commands and aggregates for its root relation
@example
class UserRepo < ROM::Repository[:users] commands :create, update: :by_pk, delete: :by_pk end rom = ROM.container(:sql, 'sqlite::memory') do |conf| conf.default.create_table(:users) do primary_key :id column :name, String end end user_repo = UserRepo.new(rom) user = user_repo.create(name: "Jane") user_repo.update(user.id, name: "Jane Doe") user_repo.delete(user.id)
@api public
Attributes
root[R]
@!attribute [r] root
@return [Relation] The root relation
Public Class Methods
inherited(klass)
click to toggle source
Sets descendant root relation
@api private
Calls superclass method
# File lib/rom/repository/root.rb, line 53 def self.inherited(klass) super klass.root(root) end
new(*)
click to toggle source
@see Repository#initialize
Calls superclass method
ROM::Repository::new
# File lib/rom/repository/root.rb, line 59 def initialize(*) super @root = set_relation(self.class.root) end