Class: ROM::Repository::Root
- Inherits:
-
ROM::Repository
- Object
- ROM::Repository
- ROM::Repository::Root
- Extended by:
- ClassMacros
- Defined in:
- lib/rom/repository/root.rb
Overview
A specialized repository type dedicated to work with a root relation
This repository type builds commands and aggregates for its root relation
Constant Summary
Constants inherited from ROM::Repository
Instance Attribute Summary collapse
- #root ⇒ Object readonly
Attributes inherited from ROM::Repository
#container, #mappers, #relations
Class Method Summary collapse
-
.inherited(klass) ⇒ Object
private
Sets descendant root relation.
Instance Method Summary collapse
-
#aggregate(*args) ⇒ RelationProxy
Compose a relation aggregate from the root relation.
- #changeset(*args) ⇒ Object
-
#initialize(container) ⇒ Root
constructor
A new instance of Root.
Methods inherited from ROM::Repository
Methods included from ClassInterface
#[], #commands, #inherited, #relations
Constructor Details
#initialize(container) ⇒ Root
Returns a new instance of Root.
47 48 49 50 |
# File 'lib/rom/repository/root.rb', line 47 def initialize(container) super @root = relations[self.class.root] end |
Instance Attribute Details
Class Method Details
.inherited(klass) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sets descendant root relation
41 42 43 44 |
# File 'lib/rom/repository/root.rb', line 41 def self.inherited(klass) super klass.root(root) end |
Instance Method Details
#aggregate(*associations) ⇒ RelationProxy #aggregate(options) ⇒ RelationProxy
Compose a relation aggregate from the root relation
72 73 74 75 76 77 78 |
# File 'lib/rom/repository/root.rb', line 72 def aggregate(*args) if args[0].is_a?(Hash) && args.size == 1 root.combine_children(args[0]) else root.combine(*args) end end |
#changeset(name, *args) ⇒ Object #changeset(data) ⇒ Changeset::Create #changeset(restriction_arg, data) ⇒ Changeset::Update
101 102 103 104 105 106 107 |
# File 'lib/rom/repository/root.rb', line 101 def changeset(*args) if args.first.is_a?(Symbol) && relations.key?(args.first) super else super(root.name, *args) end end |