5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/imedo_client_communication/context.rb', line 5
def provides_context(*names, &block)
if names.size > 1 && block_given?
raise "Either give the names of several instance variables, or one instance variable and a block"
else
if names.size == 1 && block_given?
names = { names.first => block }
elsif names.first.is_a?(Hash)
names = names.first
else
names = names.inject({}) { |hash, name| hash[name] = lambda { instance_variable_get :"@#{name}" }; hash }
end
self.context_providers.merge! names
end
end
|