Sha256: 5eb9678be6548c5d31736d4b6ef3e9a6ee337aa1fccb053a90efa9c1d3ebcee5

Contents?: true

Size: 696 Bytes

Versions: 4

Compression:

Stored size: 696 Bytes

Contents

module VinExploder
  
  class MissingAdapter < StandardError
  end
  
  class Exploder
    
    def initialize(adapter, cache=nil)
      raise MissingAdapter.new("No vin decoding vendor adapter has been provided.") if adapter.nil?
      @cache = cache ? cache : Cache::Store.new
      @adapter = adapter
    end
    
    # Get vin Explosion.
    #
    # == Parameters
    # vin:: vehicle identification number 
    #
    # == Return
    # An Explosion object containing the decoded vin attributes
    def get(vin)
      hash = @cache.fetch(vin) do
        # get from vender adapter
        @adapter.explode(vin)
      end
      Explosion.new vin, hash, hash.delete(:errors)
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vin_exploder-0.3.1 lib/vin_exploder/exploder.rb
vin_exploder-0.3.0 lib/vin_exploder/exploder.rb
vin_exploder-0.2.0 lib/vin_exploder/exploder.rb
vin_exploder-0.1.0 lib/vin_exploder/exploder.rb