lib/mks/common/methodresponse.rb in mks_common-1.0.6 vs lib/mks/common/methodresponse.rb in mks_common-1.0.7

- old
+ new

@@ -12,15 +12,15 @@ @errors = errors @total = total end def self.success_response(data, msg = nil) - MethodResponse.new(true, msg, nil, nil, nil) if data.nil? + return MethodResponse.new(true, msg, nil, nil, nil) if data.nil? if data.kind_of?(Array) || data.class.name == 'ActiveRecord::Relation' - MethodResponse.new(true, msg, [], nil, nil) if data.count.zero? - MethodResponse.new(true, msg, data[0].json(data), nil, data.count) + return MethodResponse.new(true, msg, [], nil, nil) if data.count.zero? + return MethodResponse.new(true, msg, data[0].json(data), nil, data.count) else - MethodResponse.new(true, msg, data.json, nil, nil) + return MethodResponse.new(true, msg, data.json, nil, nil) end end def self.failure_response(data) data.errors.details \ No newline at end of file