lib/rom/repository/relation_proxy.rb in rom-repository-1.0.0.rc1 vs lib/rom/repository/relation_proxy.rb in rom-repository-1.0.0.rc2
- old
+ new
@@ -62,20 +62,22 @@
#
# @overload map_with(*mappers)
# Map tuples using registered mappers
#
# @example
- # users.as(MyUserModel)
+ # users.map_with(:my_mapper, :my_other_mapper)
#
# @param [Array<Symbol>] mappers A list of mapper identifiers
#
# @return [RelationProxy] A new relation proxy with pipelined relation
#
# @api public
def map_with(*names)
if names.size == 1 && names[0].is_a?(Class)
with(meta: meta.merge(model: names[0]))
+ elsif names.size > 1 && names.any? { |name| name.is_a?(Class) }
+ raise ArgumentError, 'using custom mappers and a model is not supported'
else
names.reduce(self) { |a, e| a >> relation.mappers[e] }
end
end
alias_method :as, :map_with
@@ -223,10 +225,10 @@
__new__(result)
else
result
end
else
- super
+ raise NoMethodError, "undefined method `#{meth}' for #{relation.class.name}"
end
end
end
end
end