Update vehicle.rb

This commit is contained in:
2016-05-06 11:37:01 -04:00
parent 5fb42e8cd8
commit 757ddf87ac

View File

@@ -48,12 +48,16 @@ class Vehicle < ActiveRecord::Base
return @details['numOfDoors'] if @details
end
# Force Upper Case for VIN numbers
def self.vin=(val)
self.vin = val.upcase
end
private
# init method to pull JSON details from Edmunds
def get_details
if self.vin?
self.vin = self.vin.upcase
begin
@details = JSON.parse get_decoder.full(self.vin)
raise @details['message'] if @details['status'] == "NOT_FOUND"