Module: ROM::DataProxy
- Defined in:
- lib/rom/support/data_proxy.rb
Overview
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.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- NON_FORWARDABLE =
[ :each, :to_a, :to_ary, :kind_of?, :instance_of?, :is_a? ].freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
private
Wrapped data array.
-
#row_proc ⇒ Proc
readonly
private
Tuple processing proc.
Class Method Summary collapse
-
.included(klass) ⇒ Object
private
Extends the class with
forwardDSL and Equalizer usingdataattribute.
Instance Method Summary collapse
-
#each ⇒ Enumerator
private
Iterate over data using row_proc.
- #initialize(data, options = {}) ⇒ Object private
Instance Attribute Details
#data ⇒ Object (readonly)
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.
Wrapped data array
20 21 22 |
# File 'lib/rom/support/data_proxy.rb', line 20 def data @data end |
#row_proc ⇒ Proc (readonly)
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.
Returns tuple processing proc.
25 26 27 |
# File 'lib/rom/support/data_proxy.rb', line 25 def row_proc @row_proc end |
Class Method Details
.included(klass) ⇒ Object
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.
Extends the class with forward DSL and Equalizer using data attribute
32 33 34 35 36 37 38 39 40 |
# File 'lib/rom/support/data_proxy.rb', line 32 def self.included(klass) klass.class_eval do extend ClassMethods include Equalizer.new(:data) option :row_proc, reader: true, default: proc { |obj| obj.class.row_proc } end end |
Instance Method Details
#each ⇒ Enumerator
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.
Iterate over data using row_proc
53 54 55 56 |
# File 'lib/rom/support/data_proxy.rb', line 53 def each return to_enum unless block_given? data.each { |tuple| yield(row_proc[tuple]) } end |
#initialize(data, options = {}) ⇒ Object
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.
43 44 45 46 |
# File 'lib/rom/support/data_proxy.rb', line 43 def initialize(data, = {}) @data = data super(data, ) end |