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 2011/05/12 13:52:49 UTC

[PATCH core 3/4] Removed empty attributes from JSON response

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


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/models/base_model.rb |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/server/lib/deltacloud/models/base_model.rb b/server/lib/deltacloud/models/base_model.rb
index f287f3e..ae08f12 100644
--- a/server/lib/deltacloud/models/base_model.rb
+++ b/server/lib/deltacloud/models/base_model.rb
@@ -46,7 +46,11 @@ class BaseModel
 
   def to_hash
     out = {}
-    self.attributes.each { |attribute| out.merge!({ attribute => self.send(:"#{attribute}") } ) }
+    self.attributes.each do |attribute| 
+      if self.send(:"#{attribute}")
+        out.merge!({ attribute => self.send(:"#{attribute}") } )
+      end
+    end
     out
   end
 
-- 
1.7.4.1