Class: ConvenientService::Utils::Hash::AssertValidKeys Private
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::Hash::AssertValidKeys
- Defined in:
- lib/convenient_service/utils/hash/assert_valid_keys.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
- #hash ⇒ Object readonly private
- #valid_keys ⇒ Object readonly private
Instance Method Summary collapse
- #call ⇒ Hash private
- #initialize(hash, valid_keys) ⇒ void constructor private
Methods inherited from Support::Command
Constructor Details
#initialize(hash, valid_keys) ⇒ 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.
33 34 35 36 |
# File 'lib/convenient_service/utils/hash/assert_valid_keys.rb', line 33 def initialize(hash, valid_keys) @hash = hash @valid_keys = valid_keys.flatten end |
Instance Attribute Details
#hash ⇒ Object (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.
20 21 22 |
# File 'lib/convenient_service/utils/hash/assert_valid_keys.rb', line 20 def hash @hash end |
#valid_keys ⇒ Object (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.
26 27 28 |
# File 'lib/convenient_service/utils/hash/assert_valid_keys.rb', line 26 def valid_keys @valid_keys end |
Instance Method Details
#call ⇒ Hash
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.
45 46 47 48 49 50 51 |
# File 'lib/convenient_service/utils/hash/assert_valid_keys.rb', line 45 def call hash.each_key do |key| next if valid_keys.include?(key) ::ConvenientService.raise ::ArgumentError.new("Unknown key: #{key.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(", ")}") end end |