Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created May 1, 2009 20:25
Show Gist options
  • Select an option

  • Save jaredatron/105237 to your computer and use it in GitHub Desktop.

Select an option

Save jaredatron/105237 to your computer and use it in GitHub Desktop.
def convert_value(value)
case value
when Hash
value.with_indifferent_access
when Array
# value.collect { |e| e.is_a?(Hash) ? e.with_indifferent_access : e }
value.include(WithIndifferentHashes)
else
value
end
end
module WithIndifferentHashes
def [](*args)
value = super
return value.is_a?(Hash) ? value.with_indifferent_access : value
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment