Sha256: 0e73584ac71727c97747e0eb020a10d4d2a0a2d7ab62a9c862036dd230b7e620
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
require 'her' require 'faraday_middleware' require 'active_support/concern' require 'norseal/api/model' module Norseal module Api class ClientNotConfigured < Exception; end def self.configure(host, api_key, &block) @api = Her::API.new @api.setup :url => "http://#{host}/" do |c| c.use FaradayMiddleware::EncodeJson c.use Her::Middleware::AcceptJSON c.use Her::Middleware::FirstLevelParseJSON c.authorization :token, api_key yield c if block_given? c.adapter Faraday.default_adapter unless c.builder.handlers.include?(Faraday::Adapter::Test) end require "norseal/api/resources/collection" require "norseal/api/resources/product" require "norseal/api/resources/question" require "norseal/api/resources/manufacturer" end def self.api raise ClientNotConfigured.new("Norseal") unless @api @api end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
norseal-api-0.1.4 | lib/norseal/api.rb |