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/support/data_proxy.rb, line 30
def self.included(klass)
  klass.class_eval do
    extend ClassMethods

    include Dry::Equalizer(:data)

    option :row_proc, reader: true, default: proc { |obj| obj.class.row_proc }
  end
end
new(data, options = {}) click to toggle source

@api private

Calls superclass method
# File lib/rom/support/data_proxy.rb, line 41
def initialize(data, options = {})
  @data = data
  super(data, options)
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/support/data_proxy.rb, line 51
def each
  return to_enum unless block_given?
  data.each { |tuple| yield(row_proc[tuple]) }
end