Class: UserSessionSweeper

Inherits:
ActiveModel::Observer
  • Object
show all
Defined in:
app/controllers/user_session_sweeper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.after(controller) ⇒ Object



8
9
10
# File 'app/controllers/user_session_sweeper.rb', line 8

def self.after(controller)
  controller.session[:user_capabilities] = nil if self.user_changes?
end

.before(controller) ⇒ Object



4
5
6
7
# File 'app/controllers/user_session_sweeper.rb', line 4

def self.before(controller)
  self.user_changes = false
  true
end

.user_changes=(bool) ⇒ Object



15
16
17
# File 'app/controllers/user_session_sweeper.rb', line 15

def self.user_changes=(bool)
  Thread.current[:user_sweeper] = bool
end

.user_changes?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/controllers/user_session_sweeper.rb', line 12

def self.user_changes?
  Thread.current[:user_sweeper]
end

Instance Method Details

#after_destroy(user) ⇒ Object



26
27
28
# File 'app/controllers/user_session_sweeper.rb', line 26

def after_destroy(user)
  changed
end

#after_save(user) ⇒ Object



23
24
25
# File 'app/controllers/user_session_sweeper.rb', line 23

def after_save(user)
  changed
end

#changedObject



19
20
21
# File 'app/controllers/user_session_sweeper.rb', line 19

def changed
  self.class.user_changes = true
end