Module: ROM::DataProxy
- Defined in:
- core/lib/rom/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 =
%i[ 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
forward
DSL and Equalizer usingdata
attribute.
Instance Method Summary collapse
-
#each ⇒ Enumerator
private
Iterate over data using row_proc.
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 'core/lib/rom/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 'core/lib/rom/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 'core/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 |
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
47 48 49 50 51 |
# File 'core/lib/rom/data_proxy.rb', line 47 def each return to_enum unless block_given? data.each { |tuple| yield(row_proc[tuple]) } end |