Module: Turntabler::Assertions Private
- Included in:
- Client, Connection, Handler, PlaylistDirectory, Resource, Resource, RoomDirectory
- Defined in:
- lib/turntabler/assertions.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provides a set of helper methods for making assertions about the content of various objects
Instance Method Summary collapse
-
#assert_valid_keys(hash, *valid_keys) ⇒ nil
private
Validates that the given hash only includes the specified valid keys.
-
#assert_valid_values(value, *valid_values) ⇒ nil
private
Validates that the given value only matches one of the specified valid values.
Instance Method Details
#assert_valid_keys(hash, *valid_keys) ⇒ nil
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.
Validates that the given hash only includes the specified valid keys.
16 17 18 19 |
# File 'lib/turntabler/assertions.rb', line 16 def assert_valid_keys(hash, *valid_keys) invalid_keys = hash.keys - valid_keys raise ArgumentError, "Invalid key(s): #{invalid_keys.join(', ')}" unless invalid_keys.empty? end |
#assert_valid_values(value, *valid_values) ⇒ nil
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.
Validates that the given value only matches one of the specified valid values.
32 33 34 |
# File 'lib/turntabler/assertions.rb', line 32 def assert_valid_values(value, *valid_values) raise ArgumentError, "#{value} is an invalid value; must be one of: #{valid_values.join(', ')}" unless valid_values.include?(value) end |