diff --git a/config/reek.yml b/config/reek.yml index 748cb66..75dcf2a 100644 --- a/config/reek.yml +++ b/config/reek.yml @@ -20,8 +20,6 @@ DuplicateMethodCall: max_calls: 1 FeatureEnvy: enabled: true - exclude: - - 'ROM::Mapping#build_relation' IrresponsibleModule: enabled: true exclude: [] diff --git a/lib/rom/mapping.rb b/lib/rom/mapping.rb index ccf9b82..ab74f62 100644 --- a/lib/rom/mapping.rb +++ b/lib/rom/mapping.rb @@ -72,8 +72,7 @@ def method_missing(name, *, &block) # # @api private def build_relation(relation, &block) - definition = Definition.build(relation.header, &block) - environment[relation.name] = Relation.build(relation, definition.mapper) + environment[relation.name] = Relation.build_from(relation, &block) end end # Mapping diff --git a/lib/rom/relation.rb b/lib/rom/relation.rb index a9f2f5b..16b24df 100644 --- a/lib/rom/relation.rb +++ b/lib/rom/relation.rb @@ -58,6 +58,18 @@ def self.build(relation, mapper) new(mapper.call(relation), mapper) end + # Build a new relation from a given relation + # + # @param [Axiom::Relation] + # + # @return [Relation] + # + # @api publi + def self.build_from(relation, &block) + definition = Mapping::Definition.build(relation.header, &block) + Relation.build(relation, definition.mapper) + end + # Iterate over tuples yielded by the wrapped relation # # @example