Class: Emendate::Examples::Row
- Inherits:
-
Object
- Object
- Emendate::Examples::Row
show all
- Defined in:
- lib/emendate/examples/row.rb
Instance Method Summary
collapse
Constructor Details
#initialize(row) ⇒ Row
Returns a new instance of Row.
6
7
8
9
10
|
# File 'lib/emendate/examples/row.rb', line 6
def initialize(row)
@keys = prep(row).keys
keys.each { |field| instance_variable_set(:"@#{field}", row[field]) }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
avoid manually declaring attr_reader for every column in row
59
60
61
62
63
|
# File 'lib/emendate/examples/row.rb', line 59
def method_missing(symbol, *args)
instance_variable_get(:"@#{symbol}")
rescue
super(symbol, *args)
end
|
Instance Method Details
#data_sets ⇒ Object
12
13
14
15
16
|
# File 'lib/emendate/examples/row.rb', line 12
def data_sets
return [] if tags_data_set.blank?
tags_data_set.split(";").sort
end
|
#date_types ⇒ Object
18
19
20
21
22
|
# File 'lib/emendate/examples/row.rb', line 18
def date_types
return [] if tags_date_type.blank?
tags_date_type.split(";").sort
end
|
#respond_to_missing?(method) ⇒ Boolean
50
51
52
|
# File 'lib/emendate/examples/row.rb', line 50
def respond_to_missing?(method, *)
keys.include?(method.to_s) || super
end
|
#runnable_tests ⇒ Object
43
44
45
46
47
48
|
# File 'lib/emendate/examples/row.rb', line 43
def runnable_tests
Emendate.examples.tests.map { |test| [test, send(test.to_sym)] }
.to_h
.compact
.keys
end
|
#tagged?(type:, tags:) ⇒ Boolean
type value must be: :data_sets or :date_types
25
26
27
28
29
30
|
# File 'lib/emendate/examples/row.rb', line 25
def tagged?(type:, tags:)
all_tags = method(type).call
return false if all_tags.empty?
tags.all? { |tag| all_tags.any?(tag) }
end
|
#test_fingerprint ⇒ Object
38
39
40
41
|
# File 'lib/emendate/examples/row.rb', line 38
def test_fingerprint
opt = test_options || "no options"
"#{test_string} ||| #{opt}"
end
|
#warnings ⇒ Object
32
33
34
35
36
|
# File 'lib/emendate/examples/row.rb', line 32
def warnings
return [] if result_warnings.blank?
result_warnings.split(";")
end
|