Permalink
Browse files

Check if object data it's Array to use or not obsolete to_a function

  • Loading branch information...
1 parent da83979 commit b2cebeb98b1596ac17b9f08630a4bfa7406f9b13 @amian84 committed Jul 22, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/ohai/system.rb
View
@@ -249,9 +249,9 @@ def attributes_print(a)
json_pretty_print(data)
when String
if data.respond_to?(:lines)
- json_pretty_print(data.lines.to_a)
+ data.lines.is_a?(Array) ? json_pretty_print(data.lines.to_a) : json_pretty_print([data.lines])
else
- json_pretty_print(data.to_a)
+ data.is_a?(Array) ? json_pretty_print(data.to_a) : json_pretty_print([data])
end
else
raise ArgumentError, "I can only generate JSON for Hashes, Mashes, Arrays and Strings. You fed me a #{data.class}!"

0 comments on commit b2cebeb

Please sign in to comment.