deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [6/6] git commit: Client: Make possible to retrieve attrs from InstanceAddress (DTACLOUD-522)
Date Thu, 04 Apr 2013 06:54:36 GMT
Client: Make possible to retrieve attrs from InstanceAddress (DTACLOUD-522)


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/1cd40ce1
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/1cd40ce1
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/1cd40ce1

Branch: refs/heads/master
Commit: 1cd40ce15de49dbdc544df2a7cf8aaa30313f5d0
Parents: c981601
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Apr 3 15:57:34 2013 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200

----------------------------------------------------------------------
 .../deltacloud/client/models/instance_address.rb   |   19 +++++++++-----
 1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1cd40ce1/client/lib/deltacloud/client/models/instance_address.rb
----------------------------------------------------------------------
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


Mime
View raw message