From: František Dvořák Date: Tue, 21 Jun 2016 22:30:07 +0000 (+0200) Subject: Keep the model in native format (convert it into hash only for the serialization... X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=583decaaed26186d3e33289e685da037ffca43b8;p=now.git Keep the model in native format (convert it into hash only for the serialization for REST API). --- diff --git a/lib/api.rb b/lib/api.rb index f3c4b2d..1cff446 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -44,7 +44,7 @@ module Now begin switch_user(params['user']) networks = nebula.list_networks - JSON.pretty_generate(networks) + JSON.pretty_generate(networks.map(&:to_hash)) rescue NowError => e logger.error "[HTTP #{e.code}] #{e.message}" halt e.code, e.message @@ -56,7 +56,7 @@ module Now begin switch_user(params['user']) network = nebula.get(params['id']) - JSON.pretty_generate(network) + JSON.pretty_generate(network.to_hash) rescue NowError => e logger.error "[HTTP #{e.code}] #{e.message}" halt e.code, e.message diff --git a/lib/nebula.rb b/lib/nebula.rb index 7c8704d..5e3e7a6 100644 --- a/lib/nebula.rb +++ b/lib/nebula.rb @@ -59,7 +59,7 @@ module Now vn_pool.each do |vn| begin network = parse_network(vn) - networks << network.to_hash + networks << network rescue NowError => e logger.warn "[code #{e.code}] #{e.message}, skipping" end @@ -75,7 +75,7 @@ module Now network = parse_network(vn) - return network.to_hash + return network end private