deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/6] Client: Added has_action? support to check if given object support requested action
Date Tue, 24 Jan 2012 11:31:10 GMT
From: Michal Fojtik <mfojtik@redhat.com>

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 client/lib/base_object.rb |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/client/lib/base_object.rb b/client/lib/base_object.rb
index f880997..1af93f5 100644
--- a/client/lib/base_object.rb
+++ b/client/lib/base_object.rb
@@ -221,6 +221,15 @@ module DeltaCloud
         end
       end
 
+      alias :original_method_missing :method_missing
+
+      def method_missing(name, *args)
+        if name.to_s =~ /^has_(\w+)\?$/
+          return actions.any? { |a| a[0] == $1 }
+        end
+        original_method_missing(name, args)
+      end
+
       private
 
       def do_action(m, args)
-- 
1.7.4.4


Mime
View raw message