Module: Clook
- Defined in:
- lib/clook/consul.rb,
lib/clook.rb,
lib/clook/env.rb,
lib/clook/json.rb,
lib/clook/yaml.rb,
lib/clook/version.rb,
lib/clook/configuration.rb
Overview
TODO search services too? /v1/catalog/service/<service> v1/catalog/nodes
Defined Under Namespace
Classes: Configuration, Consul, Env, Json, Yaml
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.adapters ⇒ Object
Returns the value of attribute adapters.
9
10
11
|
# File 'lib/clook.rb', line 9
def adapters
@adapters
end
|
.configuration ⇒ Object
11
12
13
|
# File 'lib/clook.rb', line 11
def configuration
@configuration ||= Configuration.new
end
|
Class Method Details
15
16
17
|
# File 'lib/clook.rb', line 15
def configure
yield(configuration) if block_given?
end
|
.fetch(stuff, *args, &block) ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/clook.rb', line 34
def fetch(stuff, *args, &block)
value = nil
@configuration.order.each do |prio|
@adapters[prio].each do |adapter|
value ||= adapter.fetch(stuff, *args, &block)
end
end
value
end
|
.load(type, *args, &block) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/clook.rb', line 19
def load(type, *args, &block)
require "clook/#{type.to_s}"
@adapter = const_get("#{type.to_s.capitalize}")
@adapter.send :initialize, *args, &block
@adapters[type.to_sym] << @adapter
unless @configuration.order.include? type.to_sym
@configuration.order << type.to_sym
end
self
rescue LoadError
raise "Unknown adapter #{type}"
end
|
.method_missing(method_sym, *args, &block) ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/clook.rb', line 44
def method_missing(method_sym, *args, &block)
if method_sym.to_s =~ /^load_(\w+)$/
Clook.load($1, *args, &block)
else
super
end
end
|