lib/travis/client/session.rb in travis-1.6.8.travis.453.6 vs lib/travis/client/session.rb in travis-1.6.8.travis.454.6

- old
+ new

@@ -14,10 +14,11 @@ require 'json' module Travis module Client class Session + PRIMITIVE = [nil, false, true] SSL_OPTIONS = { :ca_file => Tools::Assets['cacert.pem'] } include Methods attr_reader :connection, :headers, :access_token, :instruments, :faraday_adapter, :agent_info, :ssl @@ -272,14 +273,19 @@ lift.call result end def create_entity(type, data) + return data if primitive?(data) data = { type.id_field => data } if type.id? data id = type.cast_id(data.fetch(type.id_field)) unless type.weak? entity = id ? cached(type, :id, id) { type.new(self, id) } : type.new(self, nil) entity.update_attributes(data) entity + end + + def primitive?(data) + PRIMITIVE.include? data end def error_message(e) message = e.response[:body].to_str rescue e.message JSON.parse(message).fetch('error').fetch('message') rescue message