Class: Contracts::Constraints::HashOf
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(key, value) ⇒ HashOf
constructor
A new instance of HashOf.
- #matches?(value) ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(key, value) ⇒ HashOf
Returns a new instance of HashOf.
258 259 260 261 |
# File 'lib/contracts.rb', line 258 def initialize(key, value) (@key = Constraints.coerce(key) @value = Constraints.coerce(value)) end |
Instance Method Details
#description ⇒ Object
264 |
# File 'lib/contracts.rb', line 264 def description = "Hash<#{@key.description}, #{@value.description}>" |
#matches?(value) ⇒ Boolean
263 |
# File 'lib/contracts.rb', line 263 def matches?(value) = value.is_a?(Hash) && value.all? { |k, v| @key.matches?(k) && @value.matches?(v) } |