Class: Params
Overview
All url related data is stored in params. This includes the main uri in addition to any query parameters. The router is responsible for converting any uri sections into params. Sections in the uri will override any specified parameters.
The params value can be updated the same way a model would be, only the updates will trigger an updated url via the browser history api. TODO: Support # for browsers without the history api.
Instance Attribute Summary
Attributes inherited from Model
#attributes, #parent, #path
Instance Method Summary
collapse
Methods inherited from Model
#!, #<<, #==, #assign_attribute, #expand!, #false?, #inspect, #nil?, #read_attribute, #read_new_model, #return_undefined_method, #trigger_by_attribute!, #true?
#__setup_tracking
#wrap_value, #wrap_values
included, #reactive_method_tag
Constructor Details
#initialize(*args) ⇒ Params
Returns a new instance of Params.
12
13
14
|
# File 'lib/volt/models/params.rb', line 12
def initialize(*args)
super(*args)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/volt/models/params.rb', line 33
def method_missing(method_name, *args, &block)
result = super
if method_name[0] == '_' && method_name[-1] == '='
self.value_updated
end
return result
end
|
Instance Method Details
#deep_clone ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/volt/models/params.rb', line 16
def deep_clone
new_obj = clone
new_obj.attributes = new_obj.attributes.dup
new_obj
end
|
#delete(*args) ⇒ Object
27
28
29
30
31
|
# File 'lib/volt/models/params.rb', line 27
def delete(*args)
super
value_updated
end
|
#new_array_model(*args) ⇒ Object
69
70
71
|
# File 'lib/volt/models/params.rb', line 69
def new_array_model(*args)
ParamsArray.new(*args)
end
|
#new_model(*args) ⇒ Object
65
66
67
|
# File 'lib/volt/models/params.rb', line 65
def new_model(*args)
Params.new(*args)
end
|
#run_update ⇒ Object
61
62
63
|
# File 'lib/volt/models/params.rb', line 61
def run_update
$page.params.trigger!('child_changed') if Volt.client?
end
|
#value_updated ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/volt/models/params.rb', line 44
def value_updated
if RUBY_PLATFORM == 'opal'
%x{
if (window.setTimeout && this.$run_update.bind) {
if (window.paramsUpdateTimer) {
clearTimeout(window.paramsUpdateTimer);
}
window.paramsUpdateTimer = setTimeout(this.$run_update.bind(this), 0);
}
}
end
end
|