lib/latinum/collection.rb in latinum-1.3.1 vs lib/latinum/collection.rb in latinum-1.4.0
- old
+ new
@@ -91,7 +91,20 @@
@resources.each do |key, value|
yield Resource.new(value, key)
end
end
+
+ # Generate a new collection but ignore zero values.
+ def compact
+ collection = self.class.new
+
+ @resources.each do |key, value|
+ unless value.zero?
+ collection.resources[key] = value
+ end
+ end
+
+ return collection
+ end
end
end