class Hashema::HashWithIndifferentAccess::Comparison

Private Instance Methods

actual_keys() click to toggle source
# File lib/hashema/schema.rb, line 250
def actual_keys
  @actual_keys ||= Set.new(actual.keys.map(&method(:symbol_to_string)))
end
expected_class() click to toggle source
# File lib/hashema/schema.rb, line 207
def expected_class
  ::Hash
end
expected_keys() click to toggle source
# File lib/hashema/schema.rb, line 246
def expected_keys
  @expected_keys ||= Set.new(expected.keys.map(&method(:symbol_to_string)))
end
extra_keys() click to toggle source
# File lib/hashema/schema.rb, line 211
def extra_keys
  @extra_keys ||= actual.keys.reject do |key|
    has_key?(key, expected)
  end
end
fetch(key, hash) click to toggle source
# File lib/hashema/schema.rb, line 233
def fetch(key, hash)
  return hash[symbol_to_string key] if hash.has_key? symbol_to_string key
  return hash[string_to_symbol key] if hash.has_key? string_to_symbol key
end
has_key?(key, hash) click to toggle source
# File lib/hashema/schema.rb, line 229
def has_key?(key, hash)
  hash.has_key?(symbol_to_string key) or hash.has_key?(string_to_symbol key)
end
matching_keys() click to toggle source
# File lib/hashema/schema.rb, line 223
def matching_keys
  @matching_keys ||=
    Set.new(expected.keys.map(&method(:symbol_to_string))) &
    Set.new(actual.keys.map(&method(:symbol_to_string)))
end
missing_keys() click to toggle source
# File lib/hashema/schema.rb, line 217
def missing_keys
  @missing_keys ||= expected.keys.select do |key|
    !has_key?(key, actual) and fetch(key, expected).required_if_map_value?
  end
end
string_to_symbol(key) click to toggle source
# File lib/hashema/schema.rb, line 238
def string_to_symbol(key)
  key.is_a?(String) ? key.to_sym : key
end
symbol_to_string(key) click to toggle source
# File lib/hashema/schema.rb, line 242
def symbol_to_string(key)
  key.is_a?(Symbol) ? key.to_s : key
end