Class: Rtype::Behavior::TypedHash
- Defined in:
- lib/rtype/behavior/typed_hash.rb
Overview
Typed hash behavior. empty hash allowed
Instance Method Summary collapse
- #error_message(value) ⇒ Object
-
#initialize(key_type, value_type) ⇒ TypedHash
constructor
A new instance of TypedHash.
- #valid?(value) ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(key_type, value_type) ⇒ TypedHash
Returns a new instance of TypedHash.
5 6 7 8 9 10 |
# File 'lib/rtype/behavior/typed_hash.rb', line 5 def initialize(key_type, value_type) @ktype = key_type @vtype = value_type Rtype.assert_valid_argument_type_sig_element(@ktype) Rtype.assert_valid_argument_type_sig_element(@vtype) end |
Instance Method Details
#error_message(value) ⇒ Object
24 25 26 |
# File 'lib/rtype/behavior/typed_hash.rb', line 24 def (value) "Expected #{value.inspect} to be a hash with key type #{@ktype.inspect} and value type #{@vtype.inspect}" end |