volt 0.9.4.pre2 → 0.9.4.pre3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acec655ed08b959c64ad4fa1a1d70a8c202d6061
4
- data.tar.gz: 16d6eba62257243a2ea66bacfafb64ebd4ece87a
3
+ metadata.gz: cbb8632dc480ad8c3e725df22fc50513d967aca8
4
+ data.tar.gz: 7378a263f455ca95b60a04a75fa04409f9e0111f
5
5
  SHA512:
6
- metadata.gz: 86d429de470cc56e6434e9fe0f0822d840bc4a9c8d9d2e1f686d18c01ba4bb7e709c4de84b4e474d2b9dd00c78968e5b69bb98fc804b038535892557e6b66212
7
- data.tar.gz: f5cb8e59e91b908203d7bede6ae2fcaae6e84f091d65e5a61ca6b890a721b2e79edef6bc6bc31a887ac307c1c6b0d59596e4b7b4d1d8dc3c6d40a18b5d2d1984
6
+ metadata.gz: 248aa3a47ef194d783dfd47c9ff794663170cccdd06aa66eb2bd4fb197ade72fac333f777d55134bc42d08fb65e25d525dbb9cf91ceb6c5ef53e20f25b7847af
7
+ data.tar.gz: 09b7f6c57f8296c2079788e64372f3422b373d00b0ce9e64f351f36d640806961ec11df176ef302430d01e0cb9957e81a606fb2b1014a742d30ed7242d44a88d
data/CHANGELOG.md CHANGED
@@ -4,10 +4,13 @@
4
4
  ### Added
5
5
  - ```root``` can now be called from a model to get the root model on the collection. (So if the model is on store, it will return ```store```)
6
6
  - ```store``` can now be called from inside of a model
7
+ - before_save was added to models.
8
+ - added ```cookies``` model for HttpController
7
9
 
8
10
  ### Changed
9
11
  - fixed bug with ReactiveHash#to_json
10
12
  - fixed bug with field Numeric coersion
13
+ - fixed issue with initializers not loading on client sometimes.
11
14
 
12
15
  ## 0.9.3
13
16
  [0.9.3 Update Blog Post](http://blog.voltframework.com/post/121128931859/0-9-3-stuff-you-asked-for)
@@ -1,15 +1,12 @@
1
1
  require 'volt/server/rack/http_response_header'
2
2
  require 'volt/server/rack/http_response_renderer'
3
+ require 'volt/controllers/http_controller/http_cookie_persistor'
3
4
  require 'volt/utils/lifecycle_callbacks'
4
5
 
5
6
  module Volt
6
7
  # Allow you to create controllers that act as http endpoints
7
8
  class HttpController
8
9
  include LifecycleCallbacks
9
-
10
- #TODO params is only public for testing
11
- attr_accessor :params
12
-
13
10
  # Setup before_action and after_action
14
11
  setup_action_helpers_in_class(:before_action, :after_action)
15
12
 
@@ -19,7 +16,18 @@ module Volt
19
16
  @response_headers = HttpResponseHeader.new
20
17
  @response_body = []
21
18
  @request = request
22
- @params = Volt::Model.new(request.params.symbolize_keys.merge(params), persistor: Volt::Persistors::Params)
19
+ @initial_params = params
20
+ end
21
+
22
+ def params
23
+ @params ||= begin
24
+ params = request.params.symbolize_keys.merge(@initial_params)
25
+ Volt::Model.new(params, persistor: Volt::Persistors::Params)
26
+ end
27
+ end
28
+
29
+ def cookies
30
+ @cookies ||= Volt::Model.new(request.cookies, persistor: Volt::Persistors::HttpCookiePersistor)
23
31
  end
24
32
 
25
33
  def perform(action='index')
@@ -61,7 +69,21 @@ module Volt
61
69
  @response_status = 500
62
70
  end
63
71
 
64
- Rack::Response.new(response_body, response_status, response_headers)
72
+ resp = Rack::Response.new(response_body, response_status, response_headers)
73
+
74
+ # Update any changed cookies
75
+ new_cookies = cookies.persistor.changed_cookies
76
+
77
+ new_cookies.each_pair do |key, value|
78
+ if value.is_a?(String)
79
+ value = {value: value}
80
+ end
81
+ value[:path] = '/'
82
+
83
+ resp.set_cookie(key.to_s, value)
84
+ end
85
+
86
+ resp
65
87
  end
66
88
 
67
89
  # Returns the http status code as integer
@@ -0,0 +1,22 @@
1
+ require 'volt/models/persistors/base'
2
+
3
+ module Volt
4
+ module Persistors
5
+ class HttpCookiePersistor < Base
6
+ attr_reader :changed_cookies
7
+
8
+ def initialize(*args)
9
+ super
10
+
11
+ @changed_cookies = {}
12
+ end
13
+
14
+ def changed(attribute_name)
15
+ value = @model.get(attribute_name)
16
+ value = value.to_h if value.is_a?(Volt::Model)
17
+
18
+ @changed_cookies[attribute_name] = value
19
+ end
20
+ end
21
+ end
22
+ end
@@ -56,12 +56,12 @@ module Volt
56
56
  self.fragment = fragment
57
57
  self.query = query
58
58
 
59
- assign_query_hash_to_params
59
+ result = assign_query_hash_to_params
60
60
  end
61
61
 
62
62
  scroll
63
63
 
64
- true
64
+ result
65
65
  end
66
66
 
67
67
  # Full url rebuilds the url from it's constituent parts.
@@ -158,12 +158,16 @@ module Volt
158
158
 
159
159
  fail "no routes match path: #{path}" if new_params == false
160
160
 
161
+ return false if new_params == nil
162
+
161
163
  query_hash.merge!(new_params)
162
164
 
163
165
  # Loop through the .params we already have assigned.
164
166
  lparams = params
165
167
  assign_from_old(lparams, query_hash)
166
168
  assign_new(lparams, query_hash)
169
+
170
+ true
167
171
  end
168
172
 
169
173
  # Loop through the old params, and overwrite any existing values,
@@ -72,7 +72,6 @@ module Volt
72
72
  return false if url.blank?
73
73
 
74
74
  # Normalize url
75
- # Benchmark.bm(1) do
76
75
  if @url.parse(url)
77
76
  if event
78
77
  # Handled new url
@@ -85,7 +84,6 @@ module Volt
85
84
  # return false to stop the event propigation
86
85
  return false
87
86
  end
88
- # end
89
87
 
90
88
  # Not stopping, process link normally
91
89
  true
data/lib/volt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Volt
2
2
  module Version
3
- STRING = '0.9.4.pre2'
3
+ STRING = '0.9.4.pre3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4.pre2
4
+ version: 0.9.4.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-18 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -411,6 +411,7 @@ files:
411
411
  - lib/volt/config.rb
412
412
  - lib/volt/controllers/collection_helpers.rb
413
413
  - lib/volt/controllers/http_controller.rb
414
+ - lib/volt/controllers/http_controller/http_cookie_persistor.rb
414
415
  - lib/volt/controllers/model_controller.rb
415
416
  - lib/volt/controllers/template_helpers.rb
416
417
  - lib/volt/data_stores/base_adaptor_client.rb