Module: Eco::Data::Hashes::DiffResult::Meta::ClassMethods
- Defined in:
- lib/eco/data/hashes/diff_result/meta.rb
Instance Method Summary collapse
- #all_compared_attrs ⇒ Object
-
#case_sensitive(value = nil) ⇒ Object
Whether or not the diff calc of a node should be done case sensitive or insensitive.
-
#case_sensitive? ⇒ Boolean
Are comparisons of values done case sensitive?.
-
#compare(*attrs, when_present: false) ⇒ Array<String>
The comparable attributes.
- #compared_attr_when_present?(attr) ⇒ Boolean
-
#compared_attrs ⇒ Array<String>
The comparable attributes.
-
#compared_attrs_when_present ⇒ Object
Same as
compared_attrs
but they only get compared when present in both data sources. -
#key(value = nil) ⇒ String
The attribute that is key of the node diff elements.
-
#key? ⇒ Boolean
Is there a
key
attribute defined?.
Instance Method Details
#all_compared_attrs ⇒ Object
65 66 67 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 65 def all_compared_attrs compared_attrs | compared_attrs_when_present end |
#case_sensitive(value = nil) ⇒ Object
Whether or not the diff calc of a node should be done case sensitive or insensitive.
41 42 43 44 45 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 41 def case_sensitive(value = nil) @case_sensitive = false unless instance_variable_defined?(:@case_sensitive) return @case_sensitive unless value @case_sensitive = !!value end |
#case_sensitive? ⇒ Boolean
Returns are comparisons of values done case sensitive?.
48 49 50 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 48 def case_sensitive? !!@case_sensitive end |
#compare(*attrs, when_present: false) ⇒ Array<String>
Returns the comparable attributes.
30 31 32 33 34 35 36 37 38 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 30 def compare(*attrs, when_present: false) if when_present compared_attrs_when_present.push(*attrs.map(&:to_s)).uniq! compared_attrs_when_present else compared_attrs.push(*attrs.map(&:to_s)).uniq! compared_attrs end end |
#compared_attr_when_present?(attr) ⇒ Boolean
69 70 71 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 69 def compared_attr_when_present?(attr) compared_attrs_when_present.include?(attr) end |
#compared_attrs ⇒ Array<String>
Returns the comparable attributes.
53 54 55 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 53 def compared_attrs @compared_attrs ||= [] end |
#compared_attrs_when_present ⇒ Object
if present in one source but not in another, that attribute will NOT generate a diff.
Same as compared_attrs
but they only get compared when present
in both data sources
61 62 63 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 61 def compared_attrs_when_present @compared_attrs_when_present ||= [] end |
#key(value = nil) ⇒ String
Returns the attribute that is key of the node diff elements.
18 19 20 21 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 18 def key(value = nil) return @key unless value @key = value.to_s end |
#key? ⇒ Boolean
Returns is there a key
attribute defined?.
24 25 26 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 24 def key? !!@key end |