Class: ROM::Lint::EnumerableDataset
- Defined in:
- core/lib/rom/lint/enumerable_dataset.rb
Overview
Ensures that a [ROM::EnumerableDataset] extension correctly yields arrays and tuples
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
The expected data.
-
#dataset ⇒ Object
readonly
The linted subject.
Instance Method Summary collapse
-
#initialize(dataset, data) ⇒ EnumerableDataset
constructor
Create a linter for EnumerableDataset.
-
#lint_each ⇒ Object
Lint: Ensure that +dataset+ yield tuples via +each+.
-
#lint_to_a ⇒ Object
Lint: Ensure that +dataset+'s array equals to expected +data+.
Constructor Details
#initialize(dataset, data) ⇒ EnumerableDataset
Create a linter for EnumerableDataset
28 29 30 31 |
# File 'core/lib/rom/lint/enumerable_dataset.rb', line 28 def initialize(dataset, data) @dataset = dataset @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
The expected data
20 21 22 |
# File 'core/lib/rom/lint/enumerable_dataset.rb', line 20 def data @data end |
#dataset ⇒ Object (readonly)
The linted subject
15 16 17 |
# File 'core/lib/rom/lint/enumerable_dataset.rb', line 15 def dataset @dataset end |
Instance Method Details
#lint_each ⇒ Object
Lint: Ensure that +dataset+ yield tuples via +each+
36 37 38 39 40 41 42 43 44 |
# File 'core/lib/rom/lint/enumerable_dataset.rb', line 36 def lint_each result = [] dataset.each do |tuple| result << tuple end return if result == data complain "#{dataset.class}#each must yield tuples" end |
#lint_to_a ⇒ Object
Lint: Ensure that +dataset+'s array equals to expected +data+
49 50 51 52 53 |
# File 'core/lib/rom/lint/enumerable_dataset.rb', line 49 def lint_to_a return if dataset.to_a == data complain "#{dataset.class}#to_a must cast dataset to an array" end |