Displaying 1 result from an estimated 1 matches for "usage_hash".
2010 Sep 03
1
[PATCH] Adding some control over usages in the network creation/edition form
...ices/usage_service.rb
new file mode 100644
index 0000000..d044631
--- /dev/null
+++ b/src/app/services/usage_service.rb
@@ -0,0 +1,23 @@
+module UsageService
+ include ApplicationService
+
+ def authorize
+ authorized!(Privilege::MODIFY,HardwarePool.get_default_pool)
+ end
+
+ def svc_create(usage_hash)
+ authorize
+ usage_hash[:id] = Usage.maximum(:id) + 1
+ @usage = Usage.new(usage_hash)
+ @usage.save!
+ return @usage
+ end
+
+ def svc_destroy_all(ids)
+ authorize
+ # prevent destruction of original usages (1, 2 and 3)
+ ids -= ['1','2','3']
+...