travis-api/lib/travis/services/registry.rb
Aakriti Gupta 65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00

32 lines
621 B
Ruby

module Travis
module Services
module Registry
def add(key, const = nil)
if key.is_a?(Hash)
key.each { |key, const| add(key, const) }
else
services[key.to_sym] = const
end
end
def [](key)
services[key.to_sym] || raise("can not use unregistered service #{key}. known services are: #{services.keys.inspect}")
end
private
def services
@services ||= {}
end
end
extend Registry
class << self
def register
constants(false).each { |name| const_get(name) }
end
end
end
end