current_me 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,7 +18,36 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Coming soon
21
+ ### Controllers
22
+
23
+ * When signing, use the `me=`
24
+
25
+ self.me = user
26
+
27
+ * To Transition to designated page if a user isn't signed in, use the `me!`
28
+
29
+ me! signin_path
30
+
31
+ * When redirect to the source before `me!`, use the `come_from`
32
+
33
+ redirect_to come_from
34
+
35
+ * When signing out, use the `bye`
36
+
37
+ def destroy
38
+ bye
39
+ redirect_to :root
40
+ end
41
+
42
+ ### Controllers and Views
43
+
44
+ * If current signed-in user, `me` is available
45
+
46
+ Welcome <%= me.name %>
47
+
48
+ * To verify if a user is signed in, use the `me?`
49
+
50
+ <% if me? %>
22
51
 
23
52
  ## Contributing
24
53
 
@@ -1,3 +1,3 @@
1
1
  module CurrentMe
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/current_me.rb CHANGED
@@ -2,6 +2,12 @@ require "current_me/version"
2
2
  require File.join(File.dirname(__FILE__), 'current_me', 'railtie') if defined?(Rails::Railtie)
3
3
 
4
4
  module CurrentMe
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ helper_method :me, :me?
9
+ end
10
+
5
11
  def me
6
12
  if id = session[:me]
7
13
  @me ||= User.find(id)
@@ -5,7 +5,7 @@ class SessionsController < ApplicationController
5
5
  def create
6
6
  user = User.find_by_name(params[:name])
7
7
  if user
8
- me = user
8
+ self.me = user
9
9
  redirect_to come_from || user
10
10
  else
11
11
  render 'new'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: current_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-17 00:00:00.000000000 Z
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport