lib/siteleaf/entity.rb in siteleaf-2.0.2 vs lib/siteleaf/entity.rb in siteleaf-2.1.0

- old
+ new

@@ -7,11 +7,11 @@ self.attributes = attributes end def self.all result = Client.get endpoint - result.map { |r| new(r) } if result.parsed_response.is_a? Array + result.map { |r| new(r) } if result.is_a? Array end def self.find(identifier) result = Client.get "#{endpoint}/#{identifier}" new(result) if result @@ -29,12 +29,14 @@ if identifier result = Client.put entity_endpoint, attributes else result = Client.post create_endpoint, attributes end - if result + if result.is_a?(Hash) self.attributes = result return self + else + raise 'Invalid response' end end def delete Client.delete entity_endpoint