lib/rom/repository/relation_proxy.rb in rom-repository-1.0.0.beta3 vs lib/rom/repository/relation_proxy.rb in rom-repository-1.0.0.rc1
- old
+ new
@@ -50,13 +50,26 @@
((combine? || composite?) ? relation : (relation >> mapper)).call(*args)
end
# Maps the wrapped relation with other mappers available in the registry
#
- # @param *names [Array<Symbol, Class>] Either a list of mapper identifiers
- # or a custom model class
+ # @overload map_with(model)
+ # Map tuples to the provided custom model class
#
+ # @example
+ # users.as(MyUserModel)
+ #
+ # @param [Class>] model Your custom model class
+ #
+ # @overload map_with(*mappers)
+ # Map tuples using registered mappers
+ #
+ # @example
+ # users.as(MyUserModel)
+ #
+ # @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)
@@ -65,10 +78,19 @@
names.reduce(self) { |a, e| a >> relation.mappers[e] }
end
end
alias_method :as, :map_with
+ # Return a string representation of this relation proxy
+ #
+ # @return [String]
+ #
+ # @api public
+ def inspect
+ %(#<#{relation.class} name=#{name} dataset=#{dataset.inspect}>)
+ end
+
# Infers a mapper for the wrapped relation
#
# @return [ROM::Mapper]
#
# @api private
@@ -132,14 +154,9 @@
end
# @api private
def respond_to_missing?(meth, _include_private = false)
relation.respond_to?(meth) || super
- end
-
- # @api public
- def inspect
- %(#<#{relation.class} name=#{name} dataset=#{dataset.inspect}>)
end
private
# @api private