lib/rom/relation.rb
# Iterate over tuples yielded by the wrapped relation
#
# @example
#   mapper = Class.new {
#     def load(value)
#       value.to_s
#     end
#
#     def dump(value)
#       value.to_i
#     end
#   }.new
#
#   relation = ROM::Relation.new([1, 2, 3], mapper)
#
#   relation.each do |value|
#     puts value # => '1'
#   end
#
# @yieldparam [Object]
#
# @return [Relation]
#
# @api public
Iterate over tuples yielded by the wrapped relation
Iterate over tuples yielded by the wrapped relation
def each
      return to_enum unless block_given?
      relation.each { |tuple| yield(mapper.load(tuple)) }
      self
    end
def each return to_enum unless block_given? relation . each { | tuple | yield ( mapper . load ( tuple ) ) } self end
Iterate over tuples yielded by the wrapped relation
Iterate over tuples yielded by the wrapped relation
None
Relation
None
example
mapper = Class.new { def load(value) value.to_s end def dump(value) value.to_i end }.new relation = ROM::Relation.new([1, 2, 3], mapper) relation.each do |value| puts value # => '1' end
mapper = Class . new { def load ( value ) value . to_s end def dump ( value ) value . to_i end } . new relation = ROM :: Relation . new ( [ 1 2 3 ] mapper ) relation . each do |value| puts value # = > ' 1 ' end
api
None