module Hashie::Extensions::Coercion::ClassMethods
def coerce_key(*attrs)
- Example: Coerce a "user" subhash into a User object -
Parameters:
-
into
(Class
) -- the class into which you want the key(s) coerced. -
key
(Object
) -- the key or array of keys you would like to be coerced.
def coerce_key(*attrs) @key_coercions ||= {} into = attrs.pop attrs.each { |key| @key_coercions[key] = into } end