Class: SshkeySessionSweeper

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.after(controller) ⇒ Object



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

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

.before(controller) ⇒ Object



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

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

.sshkey_changes=(bool) ⇒ Object



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

def self.sshkey_changes=(bool)
  Thread.current[:sshkey_sweeper] = bool
end

.sshkey_changes?Boolean

Returns:

  • (Boolean)


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

def self.sshkey_changes?
  Thread.current[:sshkey_sweeper]
end

Instance Method Details

#after_destroy(key) ⇒ Object



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

def after_destroy(key)
  changed
end

#after_save(key) ⇒ Object



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

def after_save(key)
  changed
end

#changedObject



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

def changed
  self.class.sshkey_changes = true
end