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_attrsbut 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
keyattribute defined?.
Instance Method Details
#all_compared_attrs ⇒ Object
68 69 70 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 68 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.
43 44 45 46 47 48 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 43 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?.
51 52 53 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 51 def case_sensitive? !!@case_sensitive end |
#compare(*attrs, when_present: false) ⇒ Array<String>
Returns the comparable attributes.
32 33 34 35 36 37 38 39 40 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 32 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
72 73 74 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 72 def compared_attr_when_present?(attr) compared_attrs_when_present.include?(attr) end |
#compared_attrs ⇒ Array<String>
Returns the comparable attributes.
56 57 58 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 56 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
64 65 66 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 64 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.
19 20 21 22 23 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 19 def key(value = nil) return @key unless value @key = value.to_s end |
#key? ⇒ Boolean
Returns is there a key attribute defined?.
26 27 28 |
# File 'lib/eco/data/hashes/diff_result/meta.rb', line 26 def key? !!@key end |