class Rasti::Types::Hash
Attributes
key_type[R]
value_type[R]
Public Class Methods
[](key_type, value_type)
click to toggle source
# File lib/rasti/types/hash.rb, line 9 def self.[](key_type, value_type) new key_type, value_type end
new(key_type, value_type)
click to toggle source
# File lib/rasti/types/hash.rb, line 20 def initialize(key_type, value_type) @key_type = key_type @value_type = value_type end
Public Instance Methods
to_s()
click to toggle source
# File lib/rasti/types/hash.rb, line 13 def to_s "#{self.class}[#{key_type}, #{value_type}]" end
Also aliased as: inspect
Private Instance Methods
transform(value)
click to toggle source
# File lib/rasti/types/hash.rb, line 29 def transform(value) MultiCaster.cast!(self, value) do |multi_caster| value.each_with_object({}) do |(k,v), hash| casted_key = multi_caster.cast type: key_type, value: k, error_key: k casted_value = multi_caster.cast type: value_type, value: v, error_key: k hash[casted_key] = casted_value end end end
valid?(value)
click to toggle source
# File lib/rasti/types/hash.rb, line 25 def valid?(value) value.is_a? ::Hash end