From 95b120e6920344a9ac27cd647a4b0c41a2f8d2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Fern=C3=A1ndez-Victorio?= Date: Wed, 12 Mar 2014 12:47:39 +0000 Subject: [PATCH] Fix issue when response contains existing class If we receive a response like 13946173456625.... and we have an existing class called Trip, the process could crash while trying to create the Trip object. The code in TravelObj#new tries to get and crate constants that belongs to a module, but it does it inheriting. The change just avoids inheriting. --- lib/tripit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tripit.rb b/lib/tripit.rb index 8dcd036..07bbb5c 100755 --- a/lib/tripit.rb +++ b/lib/tripit.rb @@ -182,8 +182,8 @@ def self.new(element) element.elements.each do |e| if /^[A-Z]/.match(e.name) name = e.name.intern - klass = if TripIt.const_defined?(name) - TripIt.const_get(name) + klass = if TripIt.const_defined?(name,false) + TripIt.const_get(name,false) else TripIt.const_set(name, Class.new(TravelObj)) end