Class: TrailAPI::Base

Inherits:
Object
  • Object
show all
Extended by:
ActionController::UrlFor, ActionDispatch::Routing::PolymorphicRoutes
Includes:
HTTParty
Defined in:
lib/trail_api/base.rb

Direct Known Subclasses

Donor, Fund, Organization

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



30
31
32
# File 'lib/trail_api/base.rb', line 30

def initialize
  #raise "You must provide an auth token" if self.class.default_options[:basic_auth].nil? 
end

Class Method Details

.api_path_for(args = {}, options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/trail_api/base.rb', line 20

def self.api_path_for( args = {} , options = {} )
  TrailAPI.load_routes
#      self.new.send :polymorphic_path, args
  TrailAPI.routes.url_helpers
end

.auth(token) ⇒ Object



26
27
28
# File 'lib/trail_api/base.rb', line 26

def self.auth( token )
  basic_auth token, "X"
end

.hashize(response) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/trail_api/base.rb', line 38

def self.hashize( response )
  if response.is_a?(Array)
    response.parsed_response.collect do |result|
      Hashie::Mash.new( result )
    end
  else
    Hashie::Mash.new response
  end
end

.url_options(options = {}) ⇒ Object



34
35
36
# File 'lib/trail_api/base.rb', line 34

def self.url_options( options = {} )
  { :host => "localhost", :port => 3000 }
end