lib/cloudstack-cli/base.rb in cloudstack-cli-1.4.0 vs lib/cloudstack-cli/base.rb in cloudstack-cli-1.4.1
- old
+ new
@@ -80,13 +80,12 @@
end
def filter_by(objects, key, value)
if objects.size < 2
return objects
- elsif !(objects.first.has_key? key)
- keys = objects.first.keys.join(", ")
+ elsif !(keys = objects.map{|i| i.keys}.flatten.uniq).include?(key)
say "WARNING: Filter invalid, no key \"#{key}\" found.", :yellow
- say("DEBUG: Supported keys are, #{keys}.", :magenta) if options[:debug]
+ say("DEBUG: Supported keys are, #{keys.join(', ')}.", :magenta) if options[:debug]
return objects
end
objects.select do |object|
object[key.to_s] =~ /#{value}/i
end