Class: Stance::EventRecord

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.dismiss_allObject



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

def self.dismiss_all
  active.each(&:dismiss)
end

.table_name_prefixObject



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

def self.table_name_prefix
  'stance_'
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/models/stance/event_record.rb', line 50

def active?
  !dismissed?
end

#dismissObject



54
55
56
# File 'app/models/stance/event_record.rb', line 54

def dismiss
  update_attribute :dismissed_at, Time.current
end

#dismissed?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/stance/event_record.rb', line 46

def dismissed?
  dismissed_at.present?
end

#event_classObject



42
43
44
# File 'app/models/stance/event_record.rb', line 42

def event_class
  @event_class ||= event_class_name.constantize
end

#event_class_nameObject



38
39
40
# File 'app/models/stance/event_record.rb', line 38

def event_class_name
  @event_class_name ||= "#{subject_type}Events::#{name.tr('.', '/').classify}"
end

#to_sObject



34
35
36
# File 'app/models/stance/event_record.rb', line 34

def to_s
  name
end