Module: Ramaze::Helper::User

Defined in:
lib/ramaze/helper/user.rb

Overview

This helper provides a convenience wrapper for handling authentication and persistence of users.

Example:

class MainController < Ramaze::Controller

def index
  if logged_in?
    "Hello #{user.name}"
  else
    A('login', :href => Rs(:login))
  end
end

def 
   if request.post?
end

end

Defined Under Namespace

Classes: Wrapper

Instance Method Summary collapse

Instance Method Details

#logged_in?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/ramaze/helper/user.rb', line 43

def logged_in?
  user._logged_in?
end

#userObject

return existing or instantiate User::Wrapper



25
26
27
28
29
# File 'lib/ramaze/helper/user.rb', line 25

def user
  model = ancestral_trait[:user_model] ||= ::User
  callback = ancestral_trait[:user_callback] ||= nil
  STATE[:user] ||= Wrapper.new(model, callback)
end

#user_login(creds = request.params) ⇒ Object

shortcut for user.user_login but default argument are request.params



33
34
35
# File 'lib/ramaze/helper/user.rb', line 33

def (creds = request.params)
  user.(creds)
end

#user_logoutObject

shortcut for user.user_logout



39
40
41
# File 'lib/ramaze/helper/user.rb', line 39

def user_logout
  user._logout
end