lib/latinum/collection.rb in latinum-1.2.0 vs lib/latinum/collection.rb in latinum-1.3.0
- old
+ new
@@ -55,9 +55,28 @@
end
return self
end
+ # Add something to this collection.
+ alias + <<
+
+ # Subtract something from this collection.
+ def - other
+ self << -other
+ end
+
+ # Allow negation of all values within the collection:
+ def -@
+ collection = self.class.new
+
+ @resources.each do |key, value|
+ collection.resources[key] = -value
+ end
+
+ return collection
+ end
+
# Get a `Resource` for the given name:
def [] key
Resource.new(@resources[key], key)
end