Class: ClientVariable::Variable

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

Direct Known Subclasses

Global

Class Method Summary collapse

Class Method Details

.clearObject



27
28
29
# File 'lib/client_variable.rb', line 27

def clear
  Request.clear
end

.get_variable(name) ⇒ Object



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

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

.globalObject



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

def global
  Global
end

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



39
40
41
42
43
44
45
46
47
48
# File 'lib/client_variable.rb', line 39

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



31
32
33
34
35
36
37
# File 'lib/client_variable.rb', line 31

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



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

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

.valuesObject



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

def values
  Request.values
end