module ROM::DataProxy

Helper module for dataset classes

It provides a constructor accepting data, header and an optional row_proc. This module is used internally by EnumerableDataset and ArrayDataset.

@private

Constants

NON_FORWARDABLE

Attributes

data[R]

Wrapped data array

@return [Object] Data object for the iterator

@api private

row_proc[R]

@return [Proc] tuple processing proc

@api private

Public Class Methods

included(klass) click to toggle source

Extends the class with `forward` DSL and Equalizer using `data` attribute

@see ClassMethods#forward

@api private

# File lib/rom/data_proxy.rb, line 32
def self.included(klass)
  klass.class_eval do
    extend ClassMethods

    include Dry::Equalizer(:data)

    option :row_proc, default: -> { self.class.row_proc }
  end
end

Public Instance Methods

each() { |row_proc| ... } click to toggle source

Iterate over data using row_proc

@return [Enumerator] if block is not given

@api private

# File lib/rom/data_proxy.rb, line 47
def each
  return to_enum unless block_given?

  data.each { |tuple| yield(row_proc[tuple]) }
end