add services
This commit is contained in:
parent
1fdcec33a4
commit
79e382ce0b
lib/travis/api
|
@ -75,6 +75,10 @@ class Travis::Api::App
|
|||
|
||||
def self.setup_travis
|
||||
Travis::Database.connect
|
||||
|
||||
Travis::Services.constants.each do |name|
|
||||
Travis.services[name.to_s.underscore.to_sym] = Travis::Services.const_get(name) unless name == :Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.load_endpoints
|
||||
|
|
|
@ -10,5 +10,12 @@ class Travis::Api::App
|
|||
before { content_type :json }
|
||||
error(ActiveRecord::RecordNotFound, Sinatra::NotFound) { not_found }
|
||||
not_found { content_type =~ /json/ ? { 'file' => 'not found' } : 'file not found' }
|
||||
|
||||
private
|
||||
|
||||
def service(key)
|
||||
const = Travis.services[key] || raise("no service registered for #{key}")
|
||||
const.new(respond_to?(:current_user) ? current_user : nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user