Class: Warning

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/warning.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.activeObject



18
19
20
# File 'app/models/warning.rb', line 18

def self.active
  where(dismissed_at: nil)
end

.dismisser_classObject



2
3
4
# File 'app/models/warning.rb', line 2

def self.dismisser_class
  Devise.mappings.values.first.class_name
end

Instance Method Details

#dismiss(user) ⇒ Object



22
23
24
# File 'app/models/warning.rb', line 22

def dismiss(user)
  update_attributes dismissed_at: Time.now, dismisser: user
end

#dismissed?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/warning.rb', line 26

def dismissed?
  !dismissed_at.nil? && !dismisser.nil?
end

#just_dismissed?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/warning.rb', line 30

def just_dismissed?
  @just_dismissed
end