volt 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +56 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Rakefile +0 -1
  5. data/app/volt/models/user.rb +1 -3
  6. data/app/volt/tasks/live_query/live_query.rb +1 -1
  7. data/app/volt/tasks/store_tasks.rb +4 -5
  8. data/app/volt/tasks/user_tasks.rb +1 -1
  9. data/lib/volt.rb +2 -6
  10. data/lib/volt/boot.rb +0 -2
  11. data/lib/volt/cli.rb +0 -1
  12. data/lib/volt/cli/asset_compile.rb +0 -2
  13. data/lib/volt/cli/console.rb +3 -4
  14. data/lib/volt/cli/generate.rb +3 -4
  15. data/lib/volt/cli/new_gem.rb +1 -3
  16. data/lib/volt/controllers/actions.rb +6 -6
  17. data/lib/volt/controllers/model_controller.rb +4 -8
  18. data/lib/volt/data_stores/base.rb +1 -2
  19. data/lib/volt/data_stores/data_store.rb +2 -2
  20. data/lib/volt/data_stores/mongo_driver.rb +3 -3
  21. data/lib/volt/extra_core/hash.rb +1 -1
  22. data/lib/volt/extra_core/inflector/inflections.rb +10 -2
  23. data/lib/volt/extra_core/logger.rb +1 -4
  24. data/lib/volt/extra_core/object.rb +1 -1
  25. data/lib/volt/models.rb +2 -4
  26. data/lib/volt/models/array_model.rb +3 -7
  27. data/lib/volt/models/associations.rb +5 -4
  28. data/lib/volt/models/buffer.rb +1 -2
  29. data/lib/volt/models/dirty.rb +2 -2
  30. data/lib/volt/models/errors.rb +1 -1
  31. data/lib/volt/models/listener_tracker.rb +1 -3
  32. data/lib/volt/models/model.rb +16 -20
  33. data/lib/volt/models/permissions.rb +15 -18
  34. data/lib/volt/models/persistors/array_store.rb +5 -10
  35. data/lib/volt/models/persistors/cookies.rb +2 -2
  36. data/lib/volt/models/persistors/model_store.rb +3 -9
  37. data/lib/volt/models/persistors/params.rb +1 -3
  38. data/lib/volt/models/persistors/query/normalizer.rb +3 -3
  39. data/lib/volt/models/persistors/query/query_listener.rb +1 -1
  40. data/lib/volt/models/persistors/store.rb +2 -2
  41. data/lib/volt/models/state_helpers.rb +1 -1
  42. data/lib/volt/models/state_manager.rb +4 -4
  43. data/lib/volt/models/url.rb +2 -6
  44. data/lib/volt/models/validations.rb +8 -13
  45. data/lib/volt/models/validators/numericality_validator.rb +2 -6
  46. data/lib/volt/models/validators/unique_validator.rb +1 -1
  47. data/lib/volt/models/validators/user_validation.rb +0 -1
  48. data/lib/volt/page/bindings/attribute_binding.rb +9 -19
  49. data/lib/volt/page/bindings/content_binding.rb +1 -1
  50. data/lib/volt/page/bindings/each_binding.rb +3 -4
  51. data/lib/volt/page/bindings/if_binding.rb +1 -1
  52. data/lib/volt/page/bindings/view_binding.rb +15 -22
  53. data/lib/volt/page/bindings/view_binding/controller_handler.rb +5 -7
  54. data/lib/volt/page/bindings/view_binding/view_lookup_for_path.rb +1 -2
  55. data/lib/volt/page/bindings/yield_binding.rb +1 -2
  56. data/lib/volt/page/channel.rb +3 -3
  57. data/lib/volt/page/document_events.rb +1 -1
  58. data/lib/volt/page/page.rb +3 -6
  59. data/lib/volt/page/path_string_renderer.rb +7 -8
  60. data/lib/volt/page/sub_context.rb +1 -3
  61. data/lib/volt/page/targets/binding_document/component_node.rb +1 -3
  62. data/lib/volt/page/tasks.rb +3 -5
  63. data/lib/volt/reactive/class_eventable.rb +2 -2
  64. data/lib/volt/reactive/computation.rb +7 -7
  65. data/lib/volt/reactive/dependency.rb +1 -1
  66. data/lib/volt/reactive/eventable.rb +3 -4
  67. data/lib/volt/reactive/reactive_accessors.rb +0 -1
  68. data/lib/volt/reactive/reactive_array.rb +4 -12
  69. data/lib/volt/router/routes.rb +1 -3
  70. data/lib/volt/server.rb +6 -6
  71. data/lib/volt/server/component_handler.rb +1 -1
  72. data/lib/volt/server/component_templates.rb +2 -2
  73. data/lib/volt/server/forking_server.rb +6 -9
  74. data/lib/volt/server/html_parser/component_view_scope.rb +2 -2
  75. data/lib/volt/server/html_parser/each_scope.rb +1 -1
  76. data/lib/volt/server/html_parser/sandlebars_parser.rb +2 -6
  77. data/lib/volt/server/html_parser/view_handler.rb +1 -1
  78. data/lib/volt/server/html_parser/view_parser.rb +1 -1
  79. data/lib/volt/server/html_parser/view_scope.rb +2 -4
  80. data/lib/volt/server/rack/asset_files.rb +1 -3
  81. data/lib/volt/server/rack/component_paths.rb +1 -3
  82. data/lib/volt/server/rack/http_request.rb +1 -3
  83. data/lib/volt/server/rack/http_resource.rb +1 -3
  84. data/lib/volt/server/rack/http_response_renderer.rb +2 -2
  85. data/lib/volt/server/rack/index_files.rb +1 -1
  86. data/lib/volt/server/rack/opal_files.rb +1 -3
  87. data/lib/volt/server/socket_connection_handler.rb +1 -3
  88. data/lib/volt/server/websocket/rack_server_adaptor.rb +1 -1
  89. data/lib/volt/server/websocket/websocket_handler.rb +1 -2
  90. data/lib/volt/spec/capybara.rb +1 -1
  91. data/lib/volt/spec/setup.rb +18 -12
  92. data/lib/volt/tasks/dispatcher.rb +1 -2
  93. data/lib/volt/tasks/task_handler.rb +1 -3
  94. data/lib/volt/utils/boolean_patch.rb +1 -1
  95. data/lib/volt/utils/event_counter.rb +2 -2
  96. data/lib/volt/utils/generic_pool.rb +5 -9
  97. data/lib/volt/utils/logging/task_argument_filterer.rb +4 -4
  98. data/lib/volt/utils/logging/task_logger.rb +2 -2
  99. data/lib/volt/utils/modes.rb +2 -2
  100. data/lib/volt/utils/promise_patch.rb +1 -2
  101. data/lib/volt/utils/read_write_lock.rb +21 -23
  102. data/lib/volt/utils/tilt_patch.rb +1 -1
  103. data/lib/volt/utils/timers.rb +3 -7
  104. data/lib/volt/utils/volt_user_error.rb +1 -1
  105. data/lib/volt/version.rb +2 -2
  106. data/lib/volt/volt/app.rb +4 -6
  107. data/lib/volt/volt/users.rb +4 -3
  108. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +1 -1
  109. data/spec/apps/kitchen_sink/app/main/controllers/server/simple_http_controller.rb +1 -1
  110. data/spec/apps/kitchen_sink/app/main/controllers/todos_controller.rb +5 -5
  111. data/spec/apps/kitchen_sink/app/main/controllers/upload_controller.rb +1 -1
  112. data/spec/apps/kitchen_sink/app/main/controllers/yield_component_controller.rb +1 -1
  113. data/spec/controllers/actions_spec.rb +9 -10
  114. data/spec/controllers/model_controller_spec.rb +1 -1
  115. data/spec/extra_core/blank_spec.rb +2 -2
  116. data/spec/extra_core/logger_spec.rb +6 -8
  117. data/spec/extra_core/string_transformations_spec.rb +3 -3
  118. data/spec/integration/bindings_spec.rb +3 -9
  119. data/spec/integration/first_last_spec.rb +1 -1
  120. data/spec/integration/missing_spec.rb +1 -2
  121. data/spec/integration/raw_html_binding.rb +2 -2
  122. data/spec/integration/todos_spec.rb +22 -0
  123. data/spec/integration/yield_spec.rb +2 -2
  124. data/spec/models/associations_spec.rb +4 -4
  125. data/spec/models/buffer_spec.rb +2 -2
  126. data/spec/models/dirty_spec.rb +10 -11
  127. data/spec/models/model_spec.rb +19 -13
  128. data/spec/models/model_state_spec.rb +1 -1
  129. data/spec/models/permissions_spec.rb +8 -12
  130. data/spec/models/url_spec.rb +1 -1
  131. data/spec/models/user_spec.rb +17 -10
  132. data/spec/models/user_validation_spec.rb +2 -3
  133. data/spec/models/validations_spec.rb +7 -10
  134. data/spec/models/validators/email_validator_spec.rb +5 -7
  135. data/spec/models/validators/format_validator_spec.rb +21 -3
  136. data/spec/models/validators/length_validator_spec.rb +12 -22
  137. data/spec/models/validators/shared_examples_for_validators.rb +1 -1
  138. data/spec/models/validators/unique_validator_spec.rb +1 -2
  139. data/spec/page/bindings/content_binding_spec.rb +1 -1
  140. data/spec/page/bindings/template_binding/view_lookup_for_path_spec.rb +0 -1
  141. data/spec/page/path_string_renderer_spec.rb +2 -3
  142. data/spec/reactive/class_eventable_spec.rb +1 -1
  143. data/spec/reactive/computation_spec.rb +30 -31
  144. data/spec/reactive/reactive_hash_spec.rb +1 -1
  145. data/spec/router/routes_spec.rb +14 -16
  146. data/spec/server/html_parser/view_handler_spec.rb +1 -1
  147. data/spec/server/html_parser/view_parser_spec.rb +0 -1
  148. data/spec/server/rack/quite_common_logger_spec.rb +3 -3
  149. data/spec/tasks/dispatcher_spec.rb +1 -1
  150. data/spec/tasks/query_tracker_spec.rb +1 -3
  151. data/spec/utils/task_argument_filtererer_spec.rb +5 -5
  152. data/templates/project/app/main/controllers/main_controller.rb +1 -1
  153. data/templates/project/spec/app/main/models/sample_model_spec.rb +2 -2
  154. data/templates/project/spec/app/main/tasks/sample_task_spec.rb +2 -2
  155. data/volt.gemspec +3 -5
  156. metadata +19 -4
@@ -30,14 +30,14 @@ module Volt
30
30
  parts << `encodeURIComponent(value)`
31
31
  parts << '; '
32
32
 
33
- parts << 'path=' << options[:path] << '; ' if options[:path]
33
+ parts << 'path=' << options[:path] << '; ' if options[:path]
34
34
  parts << 'max-age=' << options[:max_age] << '; ' if options[:max_age]
35
35
 
36
36
  if (expires = options[:expires])
37
37
  parts << 'expires=' << `expires.toGMTString()` << '; '
38
38
  end
39
39
 
40
- parts << 'domain=' << options[:domain] << '; ' if options[:domain]
40
+ parts << 'domain=' << options[:domain] << '; ' if options[:domain]
41
41
  parts << 'secure' if options[:secure]
42
42
 
43
43
  cookie_val = parts.join
@@ -23,9 +23,7 @@ module Volt
23
23
  end
24
24
 
25
25
  def loaded(initial_state = nil)
26
- if model.path == []
27
- initial_state = :loaded
28
- end
26
+ initial_state = :loaded if model.path == []
29
27
 
30
28
  model.change_state_to(:loaded_state, initial_state)
31
29
  end
@@ -143,9 +141,7 @@ module Volt
143
141
  end
144
142
 
145
143
  def event_added(event, first, first_for_event)
146
- if first_for_event && event == :changed
147
- ensure_setup
148
- end
144
+ ensure_setup if first_for_event && event == :changed
149
145
  end
150
146
 
151
147
  # Update the models based on the id/identity map. Usually these requests
@@ -156,9 +152,7 @@ module Volt
156
152
 
157
153
  if model
158
154
  data.each_pair do |key, value|
159
- if key != :_id
160
- model.send(:"_#{key}=", value)
161
- end
155
+ model.send(:"_#{key}=", value) if key != :_id
162
156
  end
163
157
  end
164
158
  end
@@ -21,9 +21,7 @@ module Volt
21
21
  end
22
22
 
23
23
  def run_update
24
- if Volt.client?
25
- $page.url.update!
26
- end
24
+ $page.url.update! if Volt.client?
27
25
  end
28
26
  end
29
27
  end
@@ -12,8 +12,8 @@ module Volt
12
12
 
13
13
  def self.merge_finds_and_move_to_front(query)
14
14
  # Map first parts to string
15
- query = query.map {|v| v[0] = v[0].to_s ; v }
16
- has_find = query.find {|v| v[0] == 'find' }
15
+ query = query.map { |v| v[0] = v[0].to_s; v }
16
+ has_find = query.find { |v| v[0] == 'find' }
17
17
 
18
18
  if has_find
19
19
  # merge any finds
@@ -48,4 +48,4 @@ module Volt
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end
@@ -49,7 +49,7 @@ module Volt
49
49
  $page.cookies.delete(:user_id)
50
50
  end
51
51
 
52
- raise err
52
+ fail err
53
53
  end
54
54
  end
55
55
 
@@ -29,7 +29,7 @@ module Volt
29
29
  model = @model.new_model(nil, options)
30
30
 
31
31
  # TODO: Might not need to assign this
32
- @model.attributes ||= {}
32
+ @model.attributes ||= {}
33
33
  @model.attributes[method_name] = model
34
34
  end
35
35
  model
@@ -40,7 +40,7 @@ module Volt
40
40
  end
41
41
 
42
42
  def inspect
43
- "<#{self.class.to_s}:#{object_id}>"
43
+ "<#{self.class}:#{object_id}>"
44
44
  end
45
45
  end
46
46
  end
@@ -8,4 +8,4 @@ module Volt
8
8
  loaded_state == :loaded
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -10,7 +10,7 @@ module Volt
10
10
  end
11
11
 
12
12
  # Called from the QueryListener when the data is loaded
13
- def change_state_to(state_name, new_state, trigger=true)
13
+ def change_state_to(state_name, new_state, trigger = true)
14
14
  # use an instance variable for the state storage
15
15
  ivar_name = :"@#{state_name}"
16
16
 
@@ -25,10 +25,11 @@ module Volt
25
25
  end
26
26
 
27
27
  private
28
+
28
29
  # Get a state ivar for state_name
29
30
  # @params [String] the name of the state variable
30
31
  # @params [Boolean] if true, one will be created if it does not exist
31
- def state_dep_for(state_name, create=true)
32
+ def state_dep_for(state_name, create = true)
32
33
  dep_ivar_name = :"@#{state_name}_dep"
33
34
  dep = instance_variable_get(dep_ivar_name)
34
35
  if !dep && create
@@ -38,6 +39,5 @@ module Volt
38
39
 
39
40
  dep
40
41
  end
41
-
42
42
  end
43
- end
43
+ end
@@ -153,9 +153,7 @@ module Volt
153
153
  # Get the params that are in the route
154
154
  new_params = @router.url_to_params(path)
155
155
 
156
- if new_params == false
157
- fail "no routes match path: #{path}"
158
- end
156
+ fail "no routes match path: #{path}" if new_params == false
159
157
 
160
158
  query_hash.merge!(new_params)
161
159
 
@@ -181,9 +179,7 @@ module Volt
181
179
  assign_from_old(old_val, new_val)
182
180
  else
183
181
  # assign value
184
- if old_val != new_val
185
- params.set(name, new_val)
186
- end
182
+ params.set(name, new_val) if old_val != new_val
187
183
  new_params.delete(name)
188
184
  end
189
185
  end
@@ -19,8 +19,8 @@ module Volt
19
19
  self.custom_validations ||= []
20
20
  custom_validations << block
21
21
  else
22
- self.validations ||= {}
23
- validations[field_name] ||= {}
22
+ self.validations ||= {}
23
+ validations[field_name] ||= {}
24
24
  validations[field_name].merge!(options)
25
25
  end
26
26
  end
@@ -67,12 +67,12 @@ module Volt
67
67
  @server_errors.delete(key)
68
68
  end
69
69
 
70
- def errors(marked_only=false)
70
+ def errors(marked_only = false)
71
71
  @errors ||= Errors.new
72
72
 
73
73
  if marked_only
74
74
  # Only return the fields that have been marked
75
- @errors.to_h.select {|key,_| marked_fields[key] }
75
+ @errors.to_h.select { |key, _| marked_fields[key] }
76
76
  else
77
77
  @errors
78
78
  end
@@ -84,11 +84,8 @@ module Volt
84
84
  errors.clear
85
85
 
86
86
  run_validations.then do
87
-
88
87
  # See if any server errors are in place and merge them in if they are
89
- if Volt.client?
90
- errors.merge!(server_errors.to_h)
91
- end
88
+ errors.merge!(server_errors.to_h) if Volt.client?
92
89
  end.then do
93
90
  run_custom_validations
94
91
  end.then do
@@ -107,10 +104,9 @@ module Volt
107
104
  return true if errs[key]
108
105
  end
109
106
 
110
- return false
107
+ false
111
108
  end
112
109
 
113
-
114
110
  private
115
111
 
116
112
  # Runs through each of the normal validations.
@@ -142,7 +138,7 @@ module Volt
142
138
  end
143
139
  end
144
140
 
145
- return promise
141
+ promise
146
142
  end
147
143
 
148
144
  def run_custom_validations
@@ -161,7 +157,7 @@ module Volt
161
157
  end
162
158
  end
163
159
 
164
- return promise
160
+ promise
165
161
  end
166
162
 
167
163
  def validation_class(validation, args)
@@ -169,6 +165,5 @@ module Volt
169
165
  rescue NameError => e
170
166
  puts "Unable to find #{validation} validator"
171
167
  end
172
-
173
168
  end
174
169
  end
@@ -37,13 +37,9 @@ module Volt
37
37
  @args.each do |arg, val|
38
38
  case arg
39
39
  when :min
40
- if @value < val
41
- add_error("number must be greater than #{val}")
42
- end
40
+ add_error("number must be greater than #{val}") if @value < val
43
41
  when :max
44
- if @value > val
45
- add_error("number must be less than #{val}")
46
- end
42
+ add_error("number must be less than #{val}") if @value > val
47
43
  end
48
44
  end
49
45
 
@@ -17,7 +17,7 @@ module Volt
17
17
  message = (args.is_a?(Hash) && args[:message]) || 'is already taken'
18
18
 
19
19
  # return the error
20
- next {field_name => [message]}
20
+ next { field_name => [message] }
21
21
  end
22
22
  end
23
23
  end
@@ -1,6 +1,5 @@
1
1
  module Volt
2
2
  # Provide methods on the model class to more easily setup user validations
3
3
  module UserValidatorHelpers
4
-
5
4
  end
6
5
  end
@@ -15,7 +15,7 @@ module Volt
15
15
 
16
16
  def setup
17
17
  # Listen for changes
18
- @computation = -> do
18
+ @computation = lambda do
19
19
  begin
20
20
  @context.instance_eval(&@getter)
21
21
  rescue => e
@@ -27,17 +27,15 @@ module Volt
27
27
  end
28
28
 
29
29
  @is_radio = `#{element}.is('[type=radio]')`
30
- if @is_radio
31
- @selected_value = `#{element}.attr('value') || ''`
32
- end
30
+ @selected_value = `#{element}.attr('value') || ''` if @is_radio
33
31
 
34
32
  # Bind so when this value updates, we update
35
33
  case @attribute_name
36
34
  when 'value'
37
- changed_event = Proc.new { changed }
35
+ changed_event = proc { changed }
38
36
  `#{element}.on('input.attrbind', #{changed_event})`
39
37
  when 'checked'
40
- changed_event = Proc.new { |event| changed(event) }
38
+ changed_event = proc { |event| changed(event) }
41
39
  `#{element}.on('change.attrbind', #{changed_event})`
42
40
  end
43
41
  end
@@ -79,13 +77,11 @@ module Volt
79
77
  # update, we can just depend on it and update directly.
80
78
  @string_template_renderer = new_value
81
79
 
82
- @string_template_renderer_computation = -> do
80
+ @string_template_renderer_computation = lambda do
83
81
  self.value = @string_template_renderer.html
84
82
  end.watch!
85
83
  else
86
- if new_value.is_a?(NilMethodCall) || new_value.nil?
87
- new_value = ''
88
- end
84
+ new_value = '' if new_value.is_a?(NilMethodCall) || new_value.nil?
89
85
 
90
86
  self.value = new_value
91
87
  end
@@ -96,9 +92,7 @@ module Volt
96
92
  when 'value'
97
93
  # TODO: only update if its not the same, this keeps it from moving the
98
94
  # cursor in text fields.
99
- if val != `(#{element}.val() || '')`
100
- `#{element}.val(#{val})`
101
- end
95
+ `#{element}.val(#{val})` if val != `(#{element}.val() || '')`
102
96
  when 'disabled'
103
97
  # Disabled is handled specially, you can either return a boolean:
104
98
  # (true being disabled, false not disabled), or you can optionally
@@ -114,13 +108,9 @@ module Volt
114
108
  end
115
109
 
116
110
  def update_checked(value)
117
- if value.is_a?(NilMethodCall) || value.nil?
118
- value = false
119
- end
111
+ value = false if value.is_a?(NilMethodCall) || value.nil?
120
112
 
121
- if @is_radio
122
- value = (@selected_value == value)
123
- end
113
+ value = (@selected_value == value) if @is_radio
124
114
 
125
115
  `#{element}.prop('checked', #{value})`
126
116
  end
@@ -10,7 +10,7 @@ module Volt
10
10
  super(page, target, context, binding_name)
11
11
 
12
12
  # Listen for changes
13
- @computation = -> do
13
+ @computation = lambda do
14
14
  begin
15
15
  res = @context.instance_eval(&getter)
16
16
  rescue => e
@@ -57,7 +57,7 @@ module Volt
57
57
  def item_removed(position)
58
58
  # Remove dependency
59
59
  @templates[position].context.locals[:_index_dependency].remove
60
- @templates[position].context.locals["_#{@item_name.to_s}_dependency".to_sym].remove
60
+ @templates[position].context.locals["_#{@item_name}_dependency".to_sym].remove
61
61
 
62
62
  @templates[position].remove_anchors
63
63
  @templates[position].remove
@@ -92,12 +92,11 @@ module Volt
92
92
  item_context.locals[:_index_value] = val
93
93
  end
94
94
 
95
-
96
95
  # Get and set value
97
96
  value_dependency = Dependency.new
98
- item_context.locals["_#{@item_name.to_s}_dependency".to_sym] = value_dependency
97
+ item_context.locals["_#{@item_name}_dependency".to_sym] = value_dependency
99
98
 
100
- item_context.locals["#{@item_name.to_s}=".to_sym] = proc do |val|
99
+ item_context.locals["#{@item_name}=".to_sym] = proc do |val|
101
100
  value_dependency.changed!
102
101
  @value[item_context.locals[:_index_value]] = val
103
102
  end
@@ -28,7 +28,7 @@ module Volt
28
28
  # manually because a promise resolved.
29
29
  @promise_dependency = Dependency.new
30
30
 
31
- @computation = -> do
31
+ @computation = lambda do
32
32
  @promise_dependency.depend
33
33
 
34
34
  update
@@ -4,15 +4,13 @@ require 'volt/page/bindings/view_binding/grouped_controllers'
4
4
  require 'volt/page/bindings/view_binding/view_lookup_for_path'
5
5
  require 'volt/page/bindings/view_binding/controller_handler'
6
6
 
7
-
8
7
  module Volt
9
8
  class ViewBinding < BaseBinding
10
-
11
9
  # @param [String] binding_in_path is the path this binding was rendered from. Used to
12
10
  # lookup paths in ViewLookupForPath
13
11
  # @param [String|nil] content_template_path is the path to the template for the content
14
12
  # provided in the tag.
15
- def initialize(page, target, context, binding_name, binding_in_path, getter, content_template_path=nil)
13
+ def initialize(page, target, context, binding_name, binding_in_path, getter, content_template_path = nil)
16
14
  super(page, target, context, binding_name)
17
15
 
18
16
  @content_template_path = content_template_path
@@ -23,7 +21,7 @@ module Volt
23
21
  @current_template = nil
24
22
 
25
23
  # Run the initial render
26
- @computation = -> do
24
+ @computation = lambda do
27
25
  # Don't try to render if this has been removed
28
26
  if @context
29
27
  # Render
@@ -97,22 +95,19 @@ module Volt
97
95
 
98
96
  # Called when the next template is ready to render
99
97
  def render_next_template(full_path, path)
100
- begin
101
- # stop_waiting_for_load
102
- remove_current_controller_and_template
98
+ remove_current_controller_and_template
103
99
 
104
- # Switch the current template
105
- @current_controller_handler = @starting_controller_handler
106
- @starting_controller_handler = nil
100
+ # Switch the current template
101
+ @current_controller_handler = @starting_controller_handler
102
+ @starting_controller_handler = nil
107
103
 
108
- # Also track the current controller directly
109
- @controller = @current_controller_handler.controller if full_path
104
+ # Also track the current controller directly
105
+ @controller = @current_controller_handler.controller if full_path
110
106
 
111
- render_template(full_path || path)
112
- rescue => e
113
- Volt.logger.error("Error during render of template at #{path}: #{e.inspect}")
114
- Volt.logger.error(e.backtrace)
115
- end
107
+ render_template(full_path || path)
108
+ rescue => e
109
+ Volt.logger.error("Error during render of template at #{path}: #{e.inspect}")
110
+ Volt.logger.error(e.backtrace)
116
111
  end
117
112
 
118
113
  def stop_waiting_for_load
@@ -189,7 +184,7 @@ module Volt
189
184
  controller_class, action = ControllerHandler.get_controller_and_action(controller_path)
190
185
 
191
186
  generated_new = false
192
- new_controller = Proc.new do
187
+ new_controller = proc do
193
188
  # Mark that we needed to generate a new controller instance (not reused
194
189
  # from the group)
195
190
  generated_new = true
@@ -212,14 +207,12 @@ module Volt
212
207
  # Call the action
213
208
  stopped = handler.call_action
214
209
 
215
- if stopped
216
- controller.instance_variable_set('@chain_stopped', true)
217
- end
210
+ controller.instance_variable_set('@chain_stopped', true) if stopped
218
211
  else
219
212
  stopped = controller.instance_variable_get('@chain_stopped')
220
213
  end
221
214
 
222
- return handler, generated_new, stopped
215
+ [handler, generated_new, stopped]
223
216
  end
224
217
 
225
218
  # The context for templates can be either a controller, or the original context.