micro_sessions 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,12 +10,6 @@ For a certain application where you're using number 3, this comes at a cost - th
10
10
 
11
11
  This could be useful in instances such as a very complex wizard where transmitting the entire history of data RESTfully via param passing may not be feasible, yet you'd still like to support multiple tabs within the same browser window separately.
12
12
 
13
- == In-Progress
14
-
15
- This gem is not useable and is being continually worked on. Will be released as 0.1.0 once reasonably working and stable.
16
-
17
- DO NOT USE!
18
-
19
13
  == Installation
20
14
 
21
15
  This gem requires ActionPack and ActiveSupport 3.0 or greater.
@@ -32,6 +26,12 @@ Simply include the middleware in your controller:
32
26
  micro_sessions
33
27
  end
34
28
 
29
+ From there you will have access to a +micro_session+ object in your controllers and views, just like the +session+ object.
30
+
31
+ def new
32
+ micro_session[:key] = "Value"
33
+ end
34
+
35
35
  By default the name of the request parameter used to differentiate micro-sessions is "_msid", though this can be configured:
36
36
 
37
37
  class ApplicationController
@@ -57,7 +57,15 @@ Session data is accessible to the controller and view through the +micro_session
57
57
  When transitioning between pages for which you'd like to keep the micro-session alive, the request parameter must be passed along with any link, form, or redirect. The preferred way is to make use of the new +:micro_session+ option on available on the +url_for+ helper, which will accept either a specific value or just "true" to use the "current" micro-session to this request:
58
58
 
59
59
  link_to user_path(@user, :micro_session => true)
60
- redirect_to user_project_path([@user, @project], :micro_session => true)
60
+
61
+ Note that depending on the context in which you're producing this URL, it may not work correctly. Unfortunately the low-level url_for call in the Rails routing engine does not have access to the controller object (and hence the micro_session object), so I can't make this work outside of simple ActionView helpers. You can always explicitly include the URL options by calling:
62
+
63
+ micro_session.url_options # => {"_msid" => "0123456789"}
64
+
65
+ Can be used something like this:
66
+
67
+
68
+ redirect_to user_path(@user, micro_session.url_options)
61
69
 
62
70
  If you wish to transmit the identifier via a form, be sure to include the hidden field:
63
71
 
@@ -66,7 +74,3 @@ If you wish to transmit the identifier via a form, be sure to include the hidden
66
74
  ...
67
75
  <% end %>
68
76
 
69
- Destroying a micro-session is as easy as:
70
-
71
- micro_session.destroy
72
-
@@ -13,7 +13,15 @@ module MicroSessions
13
13
  @controller.session[options[:key]][id] ||= {}
14
14
  end
15
15
 
16
- delegate :empty?, :[], :[]=, :to_h, :to_hash, :to => :data
16
+ def url_options
17
+ if empty?
18
+ {}
19
+ else
20
+ {options[:param] => id}
21
+ end
22
+ end
23
+
24
+ delegate :empty?, :[], :[]=, :to_h, :to_hash, :inspect, :to => :data
17
25
 
18
26
  def id
19
27
  @id ||= id_from_params || generate_id
@@ -1,3 +1,3 @@
1
1
  module MicroSessions
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micro_sessions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Hughes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-23 00:00:00 +03:00
18
+ date: 2010-10-24 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency