Module: ROM::DataProxy
- Defined in:
- 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 =
[ :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 using `data` 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
18 19 20 |
# File 'lib/rom/data_proxy.rb', line 18 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.
23 24 25 |
# File 'lib/rom/data_proxy.rb', line 23 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
30 31 32 33 34 35 36 37 38 |
# File 'lib/rom/data_proxy.rb', line 30 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
45 46 47 48 |
# File 'lib/rom/data_proxy.rb', line 45 def each return to_enum unless block_given? data.each { |tuple| yield(row_proc[tuple]) } end |