You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2010/10/06 13:42:50 UTC
[PATCH core] Added method_missing for undefined attributes in client
From: Michal Fojtik <mf...@redhat.com>
---
client/lib/deltacloud.rb | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 0eeb4e4..96674ce 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -149,6 +149,8 @@ module DeltaCloud
c.instance_eval do
attr_accessor :id
attr_accessor :uri
+
+
end
obj = xml_to_class(c, item)
end
@@ -162,6 +164,10 @@ module DeltaCloud
obj.id = item['id']
api = self
c.instance_eval do
+ define_method :method_missing do |method|
+ warn "[WARNING] Method '#{method}' is not available for this resource (#{c.name})."
+ return nil
+ end
define_method :client do
api
end
--
1.7.2.3
Re: [PATCH core] Added method_missing for undefined attributes in
client
Posted by Tomas Sedovic <ts...@redhat.com>.
ACK
On 10/06/2010 01:42 PM, mfojtik@redhat.com wrote:
> From: Michal Fojtik<mf...@redhat.com>
>
> ---
> client/lib/deltacloud.rb | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
> index 0eeb4e4..96674ce 100644
> --- a/client/lib/deltacloud.rb
> +++ b/client/lib/deltacloud.rb
> @@ -149,6 +149,8 @@ module DeltaCloud
> c.instance_eval do
> attr_accessor :id
> attr_accessor :uri
> +
> +
> end
> obj = xml_to_class(c, item)
> end
> @@ -162,6 +164,10 @@ module DeltaCloud
> obj.id = item['id']
> api = self
> c.instance_eval do
> + define_method :method_missing do |method|
> + warn "[WARNING] Method '#{method}' is not available for this resource (#{c.name})."
> + return nil
> + end
> define_method :client do
> api
> end