Class: DeviseRemoteUser::Manager
- Inherits:
-
Object
- Object
- DeviseRemoteUser::Manager
- Defined in:
- lib/devise_remote_user/manager.rb
Overview
The Manager class is responsible for connecting the appliation’s User class with remote user information in the request environment.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #create_user ⇒ Object
- #find_or_create_user ⇒ Object
- #find_user ⇒ Object
-
#initialize(env) ⇒ Manager
constructor
A new instance of Manager.
- #update_user(user) ⇒ Object
Constructor Details
#initialize(env) ⇒ Manager
Returns a new instance of Manager.
11 12 13 |
# File 'lib/devise_remote_user/manager.rb', line 11 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/devise_remote_user/manager.rb', line 9 def env @env end |
Instance Method Details
#create_user ⇒ Object
28 29 30 31 32 |
# File 'lib/devise_remote_user/manager.rb', line 28 def create_user random_password = SecureRandom.hex(16) attrs = user_criterion.merge({password: random_password, password_confirmation: random_password}) User.create(attrs) end |
#find_or_create_user ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/devise_remote_user/manager.rb', line 15 def find_or_create_user user = find_user if !user && DeviseRemoteUser.auto_create user = create_user end update_user(user) if user && DeviseRemoteUser.auto_update user end |
#find_user ⇒ Object
24 25 26 |
# File 'lib/devise_remote_user/manager.rb', line 24 def find_user User.where(user_criterion).first end |
#update_user(user) ⇒ Object
34 35 36 |
# File 'lib/devise_remote_user/manager.rb', line 34 def update_user(user) user.update_attributes(remote_user_attributes) end |