Class: SmartCore::Schema::Checker::VerifiableHash Private
- Inherits:
-
Object
- Object
- SmartCore::Schema::Checker::VerifiableHash
- Defined in:
- lib/smart_core/schema/checker/verifiable_hash.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #source ⇒ Hash<String|Symbol,Any> readonly private
Instance Method Summary collapse
- #extract(key) ⇒ SmartCore::Schema::Checker::VerifiableHash private
- #fetch(key) ⇒ Any (also: #[]) private
- #initialize(source) ⇒ void constructor private
- #key?(key) ⇒ Boolean private
- #keys ⇒ Array<String> private
Constructor Details
#initialize(source) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 18 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Hash<String|Symbol,Any> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 11 def source @source end |
Instance Method Details
#extract(key) ⇒ SmartCore::Schema::Checker::VerifiableHash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 27 def extract(key) SmartCore::Schema::Checker::VerifiableHash.new(fetch(key)) end |
#fetch(key) ⇒ Any Also known as: []
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 59 60 61 62 63 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 56 def fetch(key) # @note # Previously we used exceptional flow "hash.fetch(key) rescue hash.fetch(key.to_sym)". # This flow can generate a lot of useless objects during rescuable `KeyError` exception # (useless error messages, backtraces, etc, object that was silently suppressed). # So, the "if"-#key?-oriented flow is better (generates fewer number of objects statistically) source.key?(key) ? source.fetch(key) : source.fetch(key.to_sym) end |
#key?(key) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 46 def key?(key) source.key?(key) || source.key?(key.to_sym) end |
#keys ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/smart_core/schema/checker/verifiable_hash.rb', line 36 def keys SmartCore::Schema::KeyControl.normalize_list(source.keys) end |