travis-api/lib/travis/api/v3/constant_resolver.rb
2015-02-18 13:47:04 +01:00

23 lines
433 B
Ruby

require 'tool/thread_local'
module Travis::API::V3
module ConstantResolver
def self.extended(base)
base.resolver_cache = Tool::ThreadLocal.new
super
end
attr_accessor :resolver_cache
def [](key)
return key unless key.is_a? Symbol
resolver_cache[key] ||= const_get(key.to_s.camelize, false)
end
def extended(base)
base.extend(ConstantResolver)
super
end
end
end