Module: EventMeter::HashInput
- Defined in:
- lib/event_meter/hash_input.rb
Class Method Summary collapse
Class Method Details
.coerce(value, label) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/event_meter/hash_input.rb', line 5 def coerce(value, label) return {} if value.nil? unless value.respond_to?(:to_h) raise TypeError, "#{label} must respond to to_h" end hash = value.to_h unless hash.is_a?(Hash) raise TypeError, "#{label}#to_h must return a Hash" end hash.dup end |