Class: Gon
- Inherits:
-
Object
show all
- Defined in:
- lib/gon.rb,
lib/gon/base.rb,
lib/gon/rabl.rb,
lib/gon/watch.rb,
lib/gon/global.rb,
lib/gon/escaper.rb,
lib/gon/helpers.rb,
lib/gon/request.rb,
lib/gon/version.rb,
lib/gon/jbuilder.rb
Defined Under Namespace
Modules: Base, Escaper, GonHelpers, Helpers, Jbuilder, Rabl
Classes: Global, Request, Watch
Constant Summary
collapse
- VERSION =
'5.0.4'
Class Method Summary
collapse
Class Method Details
.all_variables ⇒ Object
54
55
56
|
# File 'lib/gon.rb', line 54
def all_variables
current_gon.gon if current_gon
end
|
.clear ⇒ Object
58
59
60
|
# File 'lib/gon.rb', line 58
def clear
current_gon.clear if current_gon
end
|
.get_variable(name) ⇒ Object
38
39
40
|
# File 'lib/gon.rb', line 38
def get_variable(name)
current_gon.gon[name]
end
|
.global ⇒ Object
15
16
17
|
# File 'lib/gon.rb', line 15
def global
Gon::Global
end
|
.inspect ⇒ Object
73
74
75
|
# File 'lib/gon.rb', line 73
def inspect
'Gon'
end
|
.jbuilder(*args) ⇒ Object
67
68
69
70
71
|
# File 'lib/gon.rb', line 67
def jbuilder(*args)
ensure_template_handler_is_defined
data, options = Gon::Jbuilder.handler(args)
store_builder_data 'jbuilder', data, options
end
|
.method_missing(method, *args, &block) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/gon.rb', line 23
def method_missing(method, *args, &block)
if method.to_s =~ /=$/
if public_method_name?(method)
raise 'You can\'t use Gon public methods for storing data'
end
if self == Gon && !current_gon
raise 'Assign request-specific gon variables only through `gon` helper, not through Gon constant'
end
set_variable(method.to_s.delete('='), args[0])
else
get_variable(method.to_s)
end
end
|
.push(data = {}) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/gon.rb', line 46
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
|
.rabl(*args) ⇒ Object
62
63
64
65
|
# File 'lib/gon.rb', line 62
def rabl(*args)
data, options = Gon::Rabl.handler(args)
store_builder_data 'rabl', data, options
end
|
.set_variable(name, value) ⇒ Object
42
43
44
|
# File 'lib/gon.rb', line 42
def set_variable(name, value)
current_gon.gon[name] = value
end
|
.watch ⇒ Object
19
20
21
|
# File 'lib/gon.rb', line 19
def watch
Gon::Watch
end
|