Class: Client::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/client_variable.rb

Direct Known Subclasses

Global

Class Method Summary collapse

Class Method Details

.clearObject



23
24
25
# File 'lib/client_variable.rb', line 23

def clear
	Request.clear
end

.get_variable(name) ⇒ Object



11
12
13
# File 'lib/client_variable.rb', line 11

def get_variable(name)
	Request.values[name]
end

.globalObject



7
8
9
# File 'lib/client_variable.rb', line 7

def global
	Global
end

.method_missing(method, *args, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/client_variable.rb', line 35

def method_missing(method, *args, &block)
	if ( method.to_s =~ /=$/ )
		if public_methods? method
			raise "You can't use Gon public methods for storing data"
		end
		set_variable(method.to_s.delete('='), args[0])
	else
		get_variable(method.to_s)
	end
end

.push(data = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/client_variable.rb', line 27

def push(data = {})
	raise "Object must have each_pair method" unless data.respond_to? :each_pair

	data.each_pair do |name, value|
		set_variable(name.to_s, value)
	end
end

.set_variable(name, value) ⇒ Object



15
16
17
# File 'lib/client_variable.rb', line 15

def set_variable(name, value)
	Request.values[name] = value
end

.valuesObject



19
20
21
# File 'lib/client_variable.rb', line 19

def values
	Request.values
end