Skip to content

Instantly share code, notes, and snippets.

@3limin4t0r
Last active December 2, 2019 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3limin4t0r/64ca80daab0d5eb4d7172e08e1e38cd9 to your computer and use it in GitHub Desktop.
Save 3limin4t0r/64ca80daab0d5eb4d7172e08e1e38cd9 to your computer and use it in GitHub Desktop.
def as_array(obj)
case obj
when Array then obj.map(&method(:as_hash))
when Hash then as_array([obj])
else obj
end
end
def as_hash(obj)
case obj
when Hash then obj.transform_values(&method(:as_array))
else obj
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment