Module: ROM::Repository::LoadingProxy::Wrap
- Included in:
- ROM::Repository::LoadingProxy
- Defined in:
- lib/rom/repository/loading_proxy/wrap.rb
Overview
Provides convenient methods for producing wrapped relations
Instance Method Summary collapse
-
#wrap(options) ⇒ LoadingProxy
Wrap other relations.
-
#wrap_parent(options) ⇒ LoadingProxy
Shortcut to wrap parents.
-
#wrapped(name, keys) ⇒ LoadingProxy
private
Return a wrapped representation of a loading-proxy relation.
Instance Method Details
#wrap(options) ⇒ LoadingProxy
Wrap other relations
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rom/repository/loading_proxy/wrap.rb', line 18 def wrap() wraps = .map { |(name, (relation, keys))| relation.wrapped(name, keys) } relation = wraps.reduce(self) { |a, e| a.relation.for_wrap(e..fetch(:keys), e.base_name) } __new__(relation, meta: { wraps: wraps }) end |
#wrap_parent(options) ⇒ LoadingProxy
Shortcut to wrap parents
38 39 40 41 42 43 44 |
# File 'lib/rom/repository/loading_proxy/wrap.rb', line 38 def wrap_parent() wrap( .each_with_object({}) { |(name, parent), h| h[name] = [parent, combine_keys(parent, :children)] } ) end |
#wrapped(name, keys) ⇒ LoadingProxy
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.
Return a wrapped representation of a loading-proxy relation
This will carry meta info used to produce a correct AST from a relation so that correct mapper can be generated
54 55 56 |
# File 'lib/rom/repository/loading_proxy/wrap.rb', line 54 def wrapped(name, keys) with(name: name, meta: { keys: keys, wrap: true }) end |