Return-Path: X-Original-To: apmail-deltacloud-commits-archive@www.apache.org Delivered-To: apmail-deltacloud-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4E548F707 for ; Thu, 4 Apr 2013 06:54:36 +0000 (UTC) Received: (qmail 51604 invoked by uid 500); 4 Apr 2013 06:54:36 -0000 Delivered-To: apmail-deltacloud-commits-archive@deltacloud.apache.org Received: (qmail 51540 invoked by uid 500); 4 Apr 2013 06:54:34 -0000 Mailing-List: contact commits-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list commits@deltacloud.apache.org Received: (qmail 51471 invoked by uid 99); 4 Apr 2013 06:54:32 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Apr 2013 06:54:32 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E896E837740; Thu, 4 Apr 2013 06:54:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mfojtik@apache.org To: commits@deltacloud.apache.org Date: Thu, 04 Apr 2013 06:54:36 -0000 Message-Id: <1012c9f830e5470bbd12bae55fcc5a52@git.apache.org> In-Reply-To: <8a09ca9baf9144c38f0849dbe28aa3a4@git.apache.org> References: <8a09ca9baf9144c38f0849dbe28aa3a4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [6/6] git commit: Client: Make possible to retrieve attrs from InstanceAddress (DTACLOUD-522) 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 Authored: Wed Apr 3 15:57:34 2013 +0200 Committer: Michal fojtik 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