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 2013/04/03 16:20:01 UTC

[PATCH core 2/5] Client: Make possible to retrieve attrs from InstanceAddress (DTACLOUD-522)

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 .../lib/deltacloud/client/models/instance_address.rb  | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/client/lib/deltacloud/client/models/instance_address.rb b/client/lib/deltacloud/client/models/instance_address.rb
index f40c264..1099c8b 100644
--- a/client/lib/deltacloud/client/models/instance_address.rb
+++ b/client/lib/deltacloud/client/models/instance_address.rb
@@ -14,10 +14,18 @@
 # under the License.
 
 module Deltacloud::Client
-  class InstanceAddress < OpenStruct
+  class InstanceAddress
 
-    attr_reader :type
-    attr_reader :value
+    attr_reader :type, :value
+
+    def initialize(type, value)
+      @type = type
+      @value = value
+    end
+
+    def [](attr)
+      instance_variable_get("@#{attr}")
+    end
 
     def to_s
       @value
@@ -25,10 +33,7 @@ module Deltacloud::Client
 
     def self.convert(address_xml_block)
       address_xml_block.map do |addr|
-        new(
-          :type => addr['type'],
-          :value => addr.text
-        )
+        new(addr['type'].to_sym, addr.text)
       end
     end
   end
-- 
1.8.1.4