Class: ROM::Lint::EnumerableDataset
- Defined in:
- lib/rom/lint/enumerable_dataset.rb
Overview
Ensures that a [ROM::EnumerableDataset] extension correctly yields arrays and tuples
Constant Summary
Constants inherited from Linter
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 viaeach
. -
#lint_to_a ⇒ Object
Lint: Ensure that
dataset
‘s array equals to expecteddata
.
Methods inherited from Linter
Constructor Details
#initialize(dataset, data) ⇒ EnumerableDataset
Create a linter for EnumerableDataset
26 27 28 29 |
# File 'lib/rom/lint/enumerable_dataset.rb', line 26 def initialize(dataset, data) @dataset = dataset @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
The expected data
18 19 20 |
# File 'lib/rom/lint/enumerable_dataset.rb', line 18 def data @data end |
#dataset ⇒ Object (readonly)
The linted subject
13 14 15 |
# File 'lib/rom/lint/enumerable_dataset.rb', line 13 def dataset @dataset end |
Instance Method Details
#lint_each ⇒ Object
Lint: Ensure that dataset
yield tuples via each
34 35 36 37 38 39 40 41 42 |
# File 'lib/rom/lint/enumerable_dataset.rb', line 34 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
47 48 49 50 51 |
# File 'lib/rom/lint/enumerable_dataset.rb', line 47 def lint_to_a return if dataset.to_a == data complain "#{dataset.class}#to_a must cast dataset to an array" end |