Here’s @solnic’s brief explanation of where this came from.
Essentially, given that you have a UserRepo
that inherits ROM::Repository[:users]
, this means that UserRepo#root
will be aliased to users
. That’s basically all there is to it.
For instance, here’s something I do in my app.
module Entities; end
class Repository < ROM::Repository::Root
include Deps[container: "persistence.rom"]
struct_namespace Entities
def find(id) = root.by_pk(id).one
def find_by(...) = root.where(...).one
end
That simple alias trick means I am able to write find
and find_by
once and use them with all repos.