class SmartCore::Schema::Checker::VerifiableHash

@api private @since 0.1.0

Attributes

source[R]

@return [Hash<String|Symbol,Any>]

@api private @since 0.1.0

Public Class Methods

new(source) click to toggle source

@param source [Hash<String|Symbol,Any>] @return [void]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/verifiable_hash.rb, line 17
def initialize(source)
  @source = source
  @lock = SmartCore::Engine::Lock.new
end

Public Instance Methods

[](key)
Alias for: fetch
extract(key) click to toggle source

@param key [String] @return [SmartCore::Schema::Checker::VerifiableHash]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/verifiable_hash.rb, line 27
def extract(key)
  @lock.synchronize { SmartCore::Schema::Checker::VerifiableHash.new(fetch(key)) }
end
fetch(key) click to toggle source

@param key [String] @return [Any]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/verifiable_hash.rb, line 53
def fetch(key)
  # rubocop:disable Style/RedundantBegin
  @lock.synchronize do
    begin
      source.fetch(key)
    rescue KeyError
      source.fetch(key.to_sym)
    end
  end
  # rubocop:enable Style/RedundantBegin
end
Also aliased as: []
key?(key) click to toggle source

@param key [String] @return [Boolean]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/verifiable_hash.rb, line 44
def key?(key)
  @lock.synchronize { source.key?(key) || source.key?(key.to_sym) }
end
keys() click to toggle source

@return [Array<String>]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/verifiable_hash.rb, line 35
def keys
  @lock.synchronize { SmartCore::Schema::KeyControl.normalize_list(source.keys) }
end