Created
August 25, 2017 22:01
-
-
Save caius/20ab19b6b2bdd1c0d90ec5afb16a58b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%- | |
# Here be hax - we find all values that are integers masked as strings and | |
# turn them into actual integers. Thanks puppet. | |
numerify = lambda do |obj| | |
case obj | |
when lambda { |o| o.respond_to?(:to_i) && o.to_i.to_s == o.to_s } | |
begin | |
Integer(obj) | |
rescue ArgumentError | |
obj | |
end | |
when Array | |
obj.map { |e| numerify.call(e) } | |
when Hash | |
obj.merge(obj) { |k, val| numerify.call(val) } | |
else | |
obj | |
end | |
end | |
-%><%= JSON.pretty_generate({@name => numerify.call(@options)}) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment