deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1235274 - /deltacloud/trunk/client/lib/base_object.rb
Date Tue, 24 Jan 2012 14:42:24 GMT
Author: mfojtik
Date: Tue Jan 24 14:42:23 2012
New Revision: 1235274

URL: http://svn.apache.org/viewvc?rev=1235274&view=rev
Log:
Client: Added has_action? support to check if given object support requested action

Signed-off-by: Michal fojtik <mfojtik@redhat.com>

Modified:
    deltacloud/trunk/client/lib/base_object.rb

Modified: deltacloud/trunk/client/lib/base_object.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/client/lib/base_object.rb?rev=1235274&r1=1235273&r2=1235274&view=diff
==============================================================================
--- deltacloud/trunk/client/lib/base_object.rb (original)
+++ deltacloud/trunk/client/lib/base_object.rb Tue Jan 24 14:42:23 2012
@@ -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)



Mime
View raw message