Sha256: b3b66bf94e97736918c1efa5911234d22bbee3bc6ce511b7c5973dfba8661fd8

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

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<Symbol>, Array<String>]
          # @return [Array<String>] 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<String>] the comparable attributes
          def compared_attrs
            @compared_attrs ||= []
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.6.3 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.6.2 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.6.1 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.6.0 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.10 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.9 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.8 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.7 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.6 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.5 lib/eco/data/hashes/diff_meta.rb
eco-helpers-2.5.4 lib/eco/data/hashes/diff_meta.rb