module Eco module Data module Hashes module DiffMeta class << self def included(base) super(base) base.extend ClassMethods end end module ClassMethods # @param value [String, NilClass] # @return [String] the attribute that is key of the node diff elements. def key(value = nil) return @key unless value @key = value.to_s end # @return [Boolean] is there a `key` attribute defined? def key? !!@key end # @param attrs [Array, Array] # @return [Array] the comparable attributes def compare(*attrs) compared_attrs.push(*attrs.map(&:to_s)).uniq! compared_attrs end # Whether or not the diff calc of a node should be done case sensitive or insensitive. def case_sensitive(value = nil) @case_sensitive = false unless instance_variable_defined?(:@case_sensitive) return @case_sensitive unless value @case_sensitive = !!value end # @return [Boolean] are comparisons of values done case sensitive? def case_sensitive? !!@case_sensitive end # @return [Array] the comparable attributes def compared_attrs @compared_attrs ||= [] end end end end end end