incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Lalancette <clala...@redhat.com>
Subject [PATCH] Add (optional) constraints to features.
Date Fri, 03 Jun 2011 13:38:08 GMT
This is useful for defining something like a maximum length
of a parameter.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
---
 server/lib/deltacloud/base_driver/features.rb |    7 ++++++-
 server/views/api/show.xml.haml                |    2 ++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index 4d557e6..b5bc3ee 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -75,10 +75,11 @@ module Deltacloud
 
     # A specific feature enabled by a driver (see +feature+)
     class Feature
-      attr_reader :decl
+      attr_reader :decl, :constraints
 
       def initialize(decl, &block)
         @decl = decl
+        @constraints = {}
         instance_eval &block if block_given?
       end
 
@@ -93,6 +94,10 @@ module Deltacloud
       def description
         decl.description
       end
+
+      def constraint(name, value)
+        @constraints[name] = value
+      end
     end
 
     def self.feature_decls
diff --git a/server/views/api/show.xml.haml b/server/views/api/show.xml.haml
index f68fd79..2b9f653 100644
--- a/server/views/api/show.xml.haml
+++ b/server/views/api/show.xml.haml
@@ -3,3 +3,5 @@
     %link{ :rel=>entry_point[0], :href=>entry_point[1] }
       - for feature in driver.features(entry_point[0])
         %feature{ :name=>feature.name }
+          - for name,value in feature.constraints
+            %constraint{ :name=>name, :value=>value }
-- 
1.7.4.4


Mime
View raw message