Module: ROM::DataProxy::ClassMethods

Included in:
ArrayDataset, EnumerableDataset
Defined in:
lib/rom/data_proxy.rb

Instance Method Summary collapse

Instance Method Details

#forward(*methods) ⇒ undefined

Forward provided methods to the underlaying data object

Examples:


class MyDataset
  include DataProxy

  forward(:find_all, :map)
end

Returns:

  • (undefined)

76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rom/data_proxy.rb', line 76

def forward(*methods)
  # FIXME: we should probably raise if one of the non-forwardable methods
  #       was provided
  (methods - NON_FORWARDABLE).each do |method_name|
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def #{method_name}(*args, &block)
        response = data.public_send(#{method_name.inspect}, *args, &block)

        if response.equal?(data)
          self
        elsif response.is_a?(data.class)
          self.class.new(response)
        else
          response
        end
      end
    RUBY
  end
end

#row_procProc

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Default no-op tuple proc

Returns:

  • (Proc)

59
60
61
# File 'lib/rom/data_proxy.rb', line 59

def row_proc
  -> tuple { tuple }
end