volt 0.8.15 → 0.8.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +11 -0
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile +1 -1
  5. data/Guardfile +2 -3
  6. data/Rakefile +1 -4
  7. data/VERSION +1 -1
  8. data/app/volt/controllers/notices_controller.rb +1 -1
  9. data/app/volt/tasks/live_query/data_store.rb +7 -7
  10. data/app/volt/tasks/live_query/live_query.rb +7 -9
  11. data/app/volt/tasks/live_query/live_query_pool.rb +13 -12
  12. data/app/volt/tasks/live_query/query_tracker.rb +4 -5
  13. data/app/volt/tasks/query_tasks.rb +9 -11
  14. data/app/volt/tasks/store_tasks.rb +4 -4
  15. data/app/volt/tasks/user_tasks.rb +1 -1
  16. data/bin/volt +2 -2
  17. data/lib/volt.rb +3 -7
  18. data/lib/volt/assets/test.rb +1 -2
  19. data/lib/volt/benchmark/benchmark.rb +3 -3
  20. data/lib/volt/boot.rb +1 -1
  21. data/lib/volt/cli.rb +18 -18
  22. data/lib/volt/cli/asset_compile.rb +8 -10
  23. data/lib/volt/cli/generate.rb +9 -11
  24. data/lib/volt/cli/new_gem.rb +51 -51
  25. data/lib/volt/config.rb +2 -3
  26. data/lib/volt/console.rb +1 -1
  27. data/lib/volt/controllers/model_controller.rb +6 -6
  28. data/lib/volt/data_stores/data_store.rb +1 -1
  29. data/lib/volt/data_stores/mongo_driver.rb +1 -1
  30. data/lib/volt/extra_core/array.rb +2 -2
  31. data/lib/volt/extra_core/blank.rb +1 -2
  32. data/lib/volt/extra_core/extra_core.rb +1 -1
  33. data/lib/volt/extra_core/inflector/methods.rb +0 -1
  34. data/lib/volt/extra_core/logger.rb +13 -7
  35. data/lib/volt/extra_core/numeric.rb +1 -1
  36. data/lib/volt/extra_core/string.rb +7 -7
  37. data/lib/volt/extra_core/stringify_keys.rb +5 -5
  38. data/lib/volt/models.rb +2 -2
  39. data/lib/volt/models/array_model.rb +18 -19
  40. data/lib/volt/models/cursor.rb +0 -1
  41. data/lib/volt/models/model.rb +17 -35
  42. data/lib/volt/models/model_hash_behaviour.rb +0 -2
  43. data/lib/volt/models/model_state.rb +1 -1
  44. data/lib/volt/models/model_wrapper.rb +1 -1
  45. data/lib/volt/models/persistors/array_store.rb +26 -13
  46. data/lib/volt/models/persistors/base.rb +1 -1
  47. data/lib/volt/models/persistors/flash.rb +2 -2
  48. data/lib/volt/models/persistors/local_store.rb +2 -3
  49. data/lib/volt/models/persistors/model_store.rb +7 -6
  50. data/lib/volt/models/persistors/params.rb +2 -2
  51. data/lib/volt/models/persistors/query/query_listener.rb +2 -0
  52. data/lib/volt/models/persistors/query/query_listener_pool.rb +1 -1
  53. data/lib/volt/models/persistors/store.rb +1 -2
  54. data/lib/volt/models/persistors/store_state.rb +2 -3
  55. data/lib/volt/models/url.rb +17 -16
  56. data/lib/volt/models/validations.rb +11 -14
  57. data/lib/volt/models/validators/length_validator.rb +3 -3
  58. data/lib/volt/models/validators/presence_validator.rb +2 -2
  59. data/lib/volt/page/bindings/attribute_binding.rb +2 -3
  60. data/lib/volt/page/bindings/base_binding.rb +1 -1
  61. data/lib/volt/page/bindings/each_binding.rb +8 -9
  62. data/lib/volt/page/bindings/event_binding.rb +2 -3
  63. data/lib/volt/page/bindings/template_binding.rb +8 -7
  64. data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +2 -1
  65. data/lib/volt/page/channel.rb +10 -10
  66. data/lib/volt/page/channel_stub.rb +1 -1
  67. data/lib/volt/page/document.rb +0 -1
  68. data/lib/volt/page/document_events.rb +4 -4
  69. data/lib/volt/page/page.rb +26 -19
  70. data/lib/volt/page/string_template_renderer.rb +2 -2
  71. data/lib/volt/page/sub_context.rb +10 -4
  72. data/lib/volt/page/targets/attribute_section.rb +1 -1
  73. data/lib/volt/page/targets/attribute_target.rb +1 -2
  74. data/lib/volt/page/targets/base_section.rb +4 -4
  75. data/lib/volt/page/targets/binding_document/base_node.rb +0 -1
  76. data/lib/volt/page/targets/binding_document/component_node.rb +4 -5
  77. data/lib/volt/page/targets/dom_section.rb +21 -22
  78. data/lib/volt/page/targets/dom_target.rb +1 -1
  79. data/lib/volt/page/targets/dom_template.rb +11 -12
  80. data/lib/volt/page/targets/helpers/comment_searchers.rb +7 -8
  81. data/lib/volt/page/tasks.rb +0 -1
  82. data/lib/volt/page/template_renderer.rb +1 -1
  83. data/lib/volt/page/url_tracker.rb +3 -3
  84. data/lib/volt/reactive/computation.rb +5 -11
  85. data/lib/volt/reactive/dependency.rb +1 -3
  86. data/lib/volt/reactive/eventable.rb +17 -4
  87. data/lib/volt/reactive/hash_dependency.rb +1 -0
  88. data/lib/volt/reactive/reactive_accessors.rb +0 -1
  89. data/lib/volt/reactive/reactive_array.rb +20 -25
  90. data/lib/volt/reactive/reactive_hash.rb +3 -3
  91. data/lib/volt/router/routes.rb +11 -13
  92. data/lib/volt/server.rb +17 -17
  93. data/lib/volt/server/component_handler.rb +2 -2
  94. data/lib/volt/server/component_templates.rb +8 -8
  95. data/lib/volt/server/html_parser/attribute_scope.rb +9 -10
  96. data/lib/volt/server/html_parser/if_view_scope.rb +2 -2
  97. data/lib/volt/server/html_parser/sandlebars_parser.rb +14 -14
  98. data/lib/volt/server/html_parser/textarea_scope.rb +1 -2
  99. data/lib/volt/server/html_parser/view_handler.rb +1 -1
  100. data/lib/volt/server/html_parser/view_parser.rb +1 -1
  101. data/lib/volt/server/html_parser/view_scope.rb +10 -10
  102. data/lib/volt/server/rack/asset_files.rb +15 -16
  103. data/lib/volt/server/rack/component_code.rb +2 -2
  104. data/lib/volt/server/rack/component_html_renderer.rb +0 -1
  105. data/lib/volt/server/rack/component_paths.rb +13 -10
  106. data/lib/volt/server/rack/index_files.rb +4 -4
  107. data/lib/volt/server/rack/opal_files.rb +4 -5
  108. data/lib/volt/server/rack/source_map_server.rb +3 -3
  109. data/lib/volt/server/socket_connection_handler.rb +3 -4
  110. data/lib/volt/server/socket_connection_handler_stub.rb +1 -1
  111. data/lib/volt/spec/setup.rb +3 -3
  112. data/lib/volt/store/mongo.rb +2 -2
  113. data/lib/volt/tasks/task_handler.rb +3 -3
  114. data/lib/volt/utils/generic_counting_pool.rb +2 -2
  115. data/lib/volt/utils/generic_pool.rb +7 -8
  116. data/lib/volt/utils/local_storage.rb +4 -4
  117. data/lib/volt/volt/environment.rb +1 -1
  118. data/spec/apps/file_loading/app/shared/config/dependencies.rb +1 -1
  119. data/spec/apps/kitchen_sink/Gemfile +0 -2
  120. data/spec/apps/kitchen_sink/app/main/config/routes.rb +5 -5
  121. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +7 -6
  122. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +3 -4
  123. data/spec/controllers/reactive_accessors_spec.rb +4 -4
  124. data/spec/extra_core/inflector_spec.rb +1 -1
  125. data/spec/extra_core/string_transformation_test_cases.rb +23 -24
  126. data/spec/extra_core/string_transformations_spec.rb +11 -12
  127. data/spec/integration/bindings_spec.rb +15 -15
  128. data/spec/integration/list_spec.rb +12 -13
  129. data/spec/integration/templates_spec.rb +3 -3
  130. data/spec/models/model_spec.rb +74 -80
  131. data/spec/models/persistors/params_spec.rb +2 -2
  132. data/spec/models/persistors/store_spec.rb +4 -4
  133. data/spec/models/validations_spec.rb +14 -23
  134. data/spec/page/bindings/content_binding_spec.rb +7 -8
  135. data/spec/page/bindings/template_binding_spec.rb +22 -24
  136. data/spec/page/sub_context_spec.rb +2 -2
  137. data/spec/reactive/computation_spec.rb +3 -3
  138. data/spec/reactive/reactive_array_spec.rb +12 -12
  139. data/spec/router/routes_spec.rb +45 -48
  140. data/spec/server/html_parser/sandlebars_parser_spec.rb +42 -42
  141. data/spec/server/html_parser/view_parser_spec.rb +132 -153
  142. data/spec/server/rack/asset_files_spec.rb +9 -8
  143. data/spec/server/rack/component_paths_spec.rb +5 -5
  144. data/spec/server/rack/rack_requests_spec.rb +3 -3
  145. data/spec/spec_helper.rb +1 -1
  146. data/spec/tasks/live_query_spec.rb +4 -5
  147. data/spec/tasks/query_tasks.rb +2 -4
  148. data/spec/tasks/query_tracker_spec.rb +29 -29
  149. data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
  150. data/spec/utils/generic_counting_pool_spec.rb +4 -4
  151. data/spec/utils/generic_pool_spec.rb +12 -12
  152. data/templates/component/config/routes.rb +2 -2
  153. data/templates/component/controllers/main_controller.rb +7 -6
  154. data/templates/newgem/app/newgem/config/dependencies.rb +1 -1
  155. data/templates/newgem/app/newgem/config/routes.rb +1 -1
  156. data/templates/project/app/main/config/routes.rb +2 -2
  157. data/templates/project/app/main/controllers/main_controller.rb +7 -6
  158. data/templates/project/spec/sample_spec.rb +2 -2
  159. data/volt.gemspec +32 -33
  160. metadata +3 -4
  161. data/lib/volt/extra_core/log.rb +0 -56
  162. data/lib/volt/extra_core/try.rb +0 -31
@@ -9,14 +9,14 @@ module Volt
9
9
 
10
10
  def changed(attribute_name)
11
11
  if RUBY_PLATFORM == 'opal'
12
- %x{
12
+ `
13
13
  if (window.setTimeout && this.$run_update.bind) {
14
14
  if (window.paramsUpdateTimer) {
15
15
  clearTimeout(window.paramsUpdateTimer);
16
16
  }
17
17
  window.paramsUpdateTimer = setTimeout(this.$run_update.bind(this), 0);
18
18
  }
19
- }
19
+ `
20
20
  end
21
21
  end
22
22
 
@@ -16,6 +16,8 @@ module Volt
16
16
 
17
17
  def add_listener
18
18
  @listening = true
19
+
20
+ # Call the backend and add the listner
19
21
  QueryTasks.add_listener(@collection, @query).then do |ret|
20
22
  results, errors = ret
21
23
 
@@ -8,7 +8,7 @@ module Volt
8
8
  # single query at once. Data updates will only be sent once as well.
9
9
  class QueryListenerPool < GenericPool
10
10
  def print
11
- puts "--- Running Queries ---"
11
+ puts '--- Running Queries ---'
12
12
 
13
13
  @pool.each_pair do |table, query_hash|
14
14
  query_hash.keys.each do |query|
@@ -4,10 +4,9 @@ require 'volt/models/persistors/model_identity_map'
4
4
  module Volt
5
5
  module Persistors
6
6
  class Store < Base
7
-
8
7
  @@identity_map = ModelIdentityMap.new
9
8
 
10
- def initialize(model, tasks=nil)
9
+ def initialize(model, tasks = nil)
11
10
  @tasks = tasks
12
11
  @model = model
13
12
 
@@ -2,9 +2,8 @@ module Volt
2
2
  module Persistors
3
3
  # StoreState provides method for a store to track its loading state.
4
4
  module StoreState
5
-
6
5
  # Called when a collection loads
7
- def loaded(initial_state=nil)
6
+ def loaded(initial_state = nil)
8
7
  change_state_to(initial_state || :not_loaded)
9
8
  end
10
9
 
@@ -15,7 +14,7 @@ module Volt
15
14
  end
16
15
 
17
16
  # Called from the QueryListener when the data is loaded
18
- def change_state_to(new_state, skip_trigger=false)
17
+ def change_state_to(new_state, skip_trigger = false)
19
18
  old_state = @state
20
19
  @state = new_state
21
20
 
@@ -54,7 +54,7 @@ module Volt
54
54
 
55
55
  scroll
56
56
 
57
- return true
57
+ true
58
58
  end
59
59
 
60
60
  # Full url rebuilds the url from it's constituent parts
@@ -78,15 +78,15 @@ module Volt
78
78
 
79
79
  if query_parts.size > 0
80
80
  self.query = query_parts.join('&')
81
- new_url += '?' + self.query
81
+ new_url += '?' + query
82
82
  end
83
83
  end
84
84
 
85
85
  # Add fragment
86
- frag = self.fragment
86
+ frag = fragment
87
87
  new_url += '#' + frag if frag.present?
88
88
 
89
- return new_url
89
+ new_url
90
90
  end
91
91
 
92
92
  # Called when the state has changed and the url in the
@@ -94,24 +94,24 @@ module Volt
94
94
  # Called when an attribute changes to update the url
95
95
  def update!
96
96
  if Volt.client?
97
- new_url = full_url()
97
+ new_url = full_url
98
98
 
99
99
  # Push the new url if pushState is supported
100
100
  # TODO: add fragment fallback
101
- %x{
101
+ `
102
102
  if (document.location.href != new_url && history && history.pushState) {
103
103
  history.pushState(null, null, new_url);
104
104
  }
105
- }
105
+ `
106
106
  end
107
107
  end
108
108
 
109
109
  def scroll
110
110
  if Volt.client?
111
- frag = self.fragment
111
+ frag = fragment
112
112
  if frag
113
113
  # Scroll to anchor via http://www.w3.org/html/wg/drafts/html/master/browsers.html#scroll-to-fragid
114
- %x{
114
+ `
115
115
  var anchor = $('#' + frag);
116
116
  if (anchor.length == 0) {
117
117
  anchor = $('*[name="' + frag + '"]:first');
@@ -120,7 +120,7 @@ module Volt
120
120
  console.log('scroll to: ', anchor.offset().top);
121
121
  $(document.body).scrollTop(anchor.offset().top);
122
122
  }
123
- }
123
+ `
124
124
  else
125
125
  # Scroll to the top by default
126
126
  `$(document.body).scrollTop(0);`
@@ -129,6 +129,7 @@ module Volt
129
129
  end
130
130
 
131
131
  private
132
+
132
133
  # Assigning the params is tricky since we don't want to trigger changed on
133
134
  # any values that have not changed. So we first loop through all current
134
135
  # url params, removing any not present in the params, while also removing
@@ -142,7 +143,7 @@ module Volt
142
143
  new_params = @router.url_to_params(path)
143
144
 
144
145
  if new_params == false
145
- raise "no routes match path: #{path}"
146
+ fail "no routes match path: #{path}"
146
147
  end
147
148
 
148
149
  query_hash.merge!(new_params)
@@ -193,7 +194,7 @@ module Volt
193
194
 
194
195
  def query_hash
195
196
  query_hash = {}
196
- qury = self.query
197
+ qury = query
197
198
  if qury
198
199
  qury.split('&').reject { |v| v == '' }.each do |part|
199
200
  parts = part.split('=').reject { |v| v == '' }
@@ -206,7 +207,7 @@ module Volt
206
207
 
207
208
  hash_part = query_hash
208
209
  sections.each_with_index do |section, index|
209
- if index == sections.size-1
210
+ if index == sections.size - 1
210
211
  # Last part, assign the value
211
212
  hash_part[section] = parts[1]
212
213
  else
@@ -216,7 +217,7 @@ module Volt
216
217
  end
217
218
  end
218
219
 
219
- return query_hash
220
+ query_hash
220
221
  end
221
222
 
222
223
  # Splits a key from a ?key=value&... parameter into its nested
@@ -240,7 +241,7 @@ module Volt
240
241
  end.join('')
241
242
  end
242
243
 
243
- def nested_params_hash(params, path=[])
244
+ def nested_params_hash(params, path = [])
244
245
  results = {}
245
246
 
246
247
  params.each_pair do |key, value|
@@ -254,7 +255,7 @@ module Volt
254
255
  end
255
256
  end
256
257
 
257
- return results
258
+ results
258
259
  end
259
260
  end
260
261
  end
@@ -11,9 +11,7 @@ module Volt
11
11
  @validations[field_name] = options
12
12
  end
13
13
 
14
- def validations
15
- @validations
16
- end
14
+ attr_reader :validations
17
15
  end
18
16
 
19
17
  def self.included(base)
@@ -22,7 +20,7 @@ module Volt
22
20
 
23
21
  # Once a field is ready, we can use include_in_errors! to start
24
22
  # showing its errors.
25
- def mark_field!(field_name, trigger_changed=true)
23
+ def mark_field!(field_name, trigger_changed = true)
26
24
  marked_fields[field_name] = true
27
25
  end
28
26
 
@@ -36,14 +34,14 @@ module Volt
36
34
 
37
35
  # TODO: Errors is being called for any validation change. We should have errors return a
38
36
  # hash like object that only calls the validation for each one.
39
- def errors(marked_only=false)
37
+ def errors(marked_only = false)
40
38
  errors = {}
41
39
 
42
40
  validations = self.class.validations
43
41
 
44
42
  if validations
45
43
  # Merge into errors, combining any error arrays
46
- merge = Proc.new do |new_errors|
44
+ merge = proc do |new_errors|
47
45
  errors.merge!(new_errors) do |key, new_val, old_val|
48
46
  new_val + old_val
49
47
  end
@@ -64,27 +62,26 @@ module Volt
64
62
  if klass
65
63
  validate_with(merge, klass, field_name, args)
66
64
  else
67
- raise "validation type #{validation} is not specified."
65
+ fail "validation type #{validation} is not specified."
68
66
  end
69
67
  end
70
68
  end
71
69
  end
72
70
 
73
- return errors
71
+ errors
74
72
  end
75
73
 
76
74
  private
75
+
77
76
  # calls the validate method on the class, passing the right arguments.
78
77
  def validate_with(merge, klass, field_name, args)
79
- return merge.call(klass.validate(self, field_name, args))
78
+ merge.call(klass.validate(self, field_name, args))
80
79
  end
81
80
 
82
81
  def validation_class(validation, args)
83
- begin
84
- Volt.const_get(:"#{validation.camelize}Validator")
85
- rescue NameError => e
86
- puts "Unable to find #{validation} validator"
87
- end
82
+ Volt.const_get(:"#{validation.camelize}Validator")
83
+ rescue NameError => e
84
+ puts "Unable to find #{validation} validator"
88
85
  end
89
86
  end
90
87
  end
@@ -11,11 +11,11 @@ module Volt
11
11
  elsif args.is_a?(Hash)
12
12
  min = args[:length] || args[:minimum]
13
13
  max = args[:maximum]
14
- raise "length or minimum must be specified" unless min.is_a?(Fixnum)
14
+ fail 'length or minimum must be specified' unless min.is_a?(Fixnum)
15
15
 
16
16
  message = args[:message]
17
17
  else
18
- raise "The arguments to length must be a number or a hash"
18
+ fail 'The arguments to length must be a number or a hash'
19
19
  end
20
20
 
21
21
  if !value || value.size < min
@@ -24,7 +24,7 @@ module Volt
24
24
  errors[field_name] = [message || "must be less than #{args} characters"]
25
25
  end
26
26
 
27
- return errors
27
+ errors
28
28
  end
29
29
  end
30
30
  end
@@ -7,13 +7,13 @@ module Volt
7
7
  if args.is_a?(Hash) && args[:message]
8
8
  message = args[:message]
9
9
  else
10
- message = "must be specified"
10
+ message = 'must be specified'
11
11
  end
12
12
 
13
13
  errors[field_name] = [message]
14
14
  end
15
15
 
16
- return errors
16
+ errors
17
17
  end
18
18
  end
19
19
  end
@@ -14,7 +14,6 @@ module Volt
14
14
  end
15
15
 
16
16
  def setup
17
-
18
17
  # Listen for changes
19
18
  @computation = -> do
20
19
  begin
@@ -39,7 +38,7 @@ module Volt
39
38
  end
40
39
  end
41
40
 
42
- def changed(event=nil)
41
+ def changed(event = nil)
43
42
  case @attribute_name
44
43
  when 'value'
45
44
  current_value = element.value
@@ -134,7 +133,7 @@ module Volt
134
133
  end
135
134
 
136
135
  def remove_anchors
137
- raise "attribute bindings do not have anchors, can not remove them"
136
+ fail 'attribute bindings do not have anchors, can not remove them'
138
137
  end
139
138
  end
140
139
  end
@@ -18,7 +18,7 @@ module Volt
18
18
  @context = context
19
19
  @binding_name = binding_name
20
20
 
21
- @@binding_number ||= 10000
21
+ @@binding_number ||= 10_000
22
22
  end
23
23
 
24
24
  def dom_section
@@ -45,10 +45,10 @@ module Volt
45
45
  values_size = values.size
46
46
 
47
47
  # Start over, re-create all nodes
48
- (templates_size-1).downto(0) do |index|
48
+ (templates_size - 1).downto(0) do |index|
49
49
  item_removed(index)
50
50
  end
51
- 0.upto(values_size-1) do |index|
51
+ 0.upto(values_size - 1) do |index|
52
52
  item_added(index)
53
53
  end
54
54
  end
@@ -80,19 +80,19 @@ module Volt
80
80
  end
81
81
 
82
82
  # TODORW: :parent => @value may change
83
- item_context = SubContext.new({:_index_value => position, :parent => @value}, @context)
84
- item_context.locals[@item_name.to_sym] = Proc.new { @value[item_context.locals[:_index_value]] }
83
+ item_context = SubContext.new({ _index_value: position, parent: @value }, @context)
84
+ item_context.locals[@item_name.to_sym] = proc { @value[item_context.locals[:_index_value]] }
85
85
 
86
86
  position_dependency = Dependency.new
87
87
  item_context.locals[:index_dependency] = position_dependency
88
88
 
89
89
  # Get and set index
90
- item_context.locals[:index=] = Proc.new do |val|
90
+ item_context.locals[:index=] = proc do |val|
91
91
  position_dependency.changed!
92
92
  item_context.locals[:_index_value] = val
93
93
  end
94
94
 
95
- item_context.locals[:index] = Proc.new do
95
+ item_context.locals[:index] = proc do
96
96
  position_dependency.depend
97
97
  item_context.locals[:_index_value]
98
98
  end
@@ -108,7 +108,7 @@ module Volt
108
108
  def update_indexes_after(start_index)
109
109
  size = @templates.size
110
110
  if size > 0
111
- start_index.upto(size-1) do |index|
111
+ start_index.upto(size - 1) do |index|
112
112
  @templates[index].context.locals[:index=].call(index)
113
113
  end
114
114
  end
@@ -118,10 +118,9 @@ module Volt
118
118
  return [] if values.is_a?(Model) || values.is_a?(Exception)
119
119
  values = values.attributes if values.respond_to?(:attributes)
120
120
 
121
- return values
121
+ values
122
122
  end
123
123
 
124
-
125
124
  # When this each_binding is removed, cleanup.
126
125
  def remove
127
126
  @computation.stop
@@ -1,7 +1,7 @@
1
1
  require 'volt/page/bindings/base_binding'
2
2
 
3
3
  module Volt
4
- # TODO: We need to figure out how we want to wrap JS events
4
+ # TODO: We need to figure out how we want to wrap JS events
5
5
  class JSEvent
6
6
  attr_reader :js_event
7
7
 
@@ -26,7 +26,6 @@ module Volt
26
26
  end
27
27
  end
28
28
 
29
-
30
29
  class EventBinding < BaseBinding
31
30
  attr_accessor :context, :binding_name
32
31
 
@@ -34,7 +33,7 @@ module Volt
34
33
  super(page, target, context, binding_name)
35
34
  @event_name = event_name
36
35
 
37
- handler = Proc.new do |js_event|
36
+ handler = proc do |js_event|
38
37
  event = JSEvent.new(js_event)
39
38
  event.prevent_default! if event_name == 'submit'
40
39
 
@@ -55,11 +55,11 @@ module Volt
55
55
  # 2. controller - main
56
56
  # 3. view - main
57
57
  # 4. section - body
58
- def path_for_template(lookup_path, force_section=nil)
58
+ def path_for_template(lookup_path, force_section = nil)
59
59
  parts = lookup_path.split('/')
60
60
  parts_size = parts.size
61
61
 
62
- default_parts = ['main', 'main', 'index', 'body']
62
+ default_parts = %w(main main index body)
63
63
 
64
64
  # When forcing a sub template, we can default the sub template section
65
65
  default_parts[-1] = force_section if force_section
@@ -96,10 +96,10 @@ module Volt
96
96
  end
97
97
  end
98
98
 
99
- return nil, nil
99
+ [nil, nil]
100
100
  end
101
101
 
102
- def update(path, section_or_arguments=nil, options={})
102
+ def update(path, section_or_arguments = nil, options = {})
103
103
  Computation.run_without_tracking do
104
104
  # Remove existing template and call _removed
105
105
  controller_send(:"#{@action}_removed") if @action && @controller
@@ -144,7 +144,7 @@ module Volt
144
144
  # In the browser, we want to keep a grouped controller around during a single run
145
145
  # of the event loop. To make that happen, we clear it on the next tick.
146
146
  `setImmediate(function() {`
147
- clear_grouped_controller
147
+ clear_grouped_controller
148
148
  `});`
149
149
  else
150
150
  # For the backend, clear it immediately
@@ -161,7 +161,7 @@ module Volt
161
161
 
162
162
  # The context for templates can be either a controller, or the original context.
163
163
  def render_template(full_path, controller_path)
164
- args = @arguments ? [SubContext.new(@arguments)] : []
164
+ args = @arguments ? [SubContext.new(@arguments, nil, true)] : []
165
165
 
166
166
  @controller = nil
167
167
 
@@ -228,6 +228,7 @@ module Volt
228
228
  end
229
229
 
230
230
  private
231
+
231
232
  # Sends the action to the controller if it exists
232
233
  def controller_send(action_name)
233
234
  if @controller.respond_to?(action_name)
@@ -260,7 +261,7 @@ module Volt
260
261
  end
261
262
  end
262
263
 
263
- return obj, action
264
+ [obj, action]
264
265
  end
265
266
  end
266
267
  end