Class: TopicTimer
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TopicTimer
show all
- Includes:
- Trashable
- Defined in:
- app/models/topic_timer.rb
Constant Summary
collapse
- MAX_DURATION_MINUTES =
20.years.to_i / 60
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Trashable
#recover!, #trash!, #trashed?
Class Method Details
.destructive_types ⇒ Object
103
104
105
|
# File 'app/models/topic_timer.rb', line 103
def self.destructive_types
@_destructive_types ||= types.only(:delete, :delete_replies)
end
|
.private_types ⇒ Object
99
100
101
|
# File 'app/models/topic_timer.rb', line 99
def self.private_types
@_private_types ||= types.only(:reminder, :clear_slow_mode)
end
|
.public_types ⇒ Object
95
96
97
|
# File 'app/models/topic_timer.rb', line 95
def self.public_types
@_public_types ||= types.except(:reminder, :clear_slow_mode)
end
|
.type_job_map ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'app/models/topic_timer.rb', line 66
def self.type_job_map
{
close: :close_topic,
open: :open_topic,
publish_to_category: :publish_topic_to_category,
delete: :delete_topic,
reminder: :topic_reminder,
bump: :bump_topic,
delete_replies: :delete_replies,
silent_close: :close_topic,
clear_slow_mode: :clear_slow_mode,
}
end
|
.types ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/models/topic_timer.rb', line 80
def self.types
@types ||=
Enum.new(
close: 1,
open: 2,
publish_to_category: 3,
delete: 4,
reminder: 5,
bump: 6,
delete_replies: 7,
silent_close: 8,
clear_slow_mode: 9,
)
end
|
Instance Method Details
#enqueue_typed_job(time: nil) ⇒ Object
62
63
64
|
# File 'app/models/topic_timer.rb', line 62
def enqueue_typed_job(time: nil)
self.send("schedule_auto_#{status_type_name}_job")
end
|
#private_type? ⇒ Boolean
111
112
113
|
# File 'app/models/topic_timer.rb', line 111
def private_type?
!!self.class.private_types[self.status_type]
end
|
#public_type? ⇒ Boolean
107
108
109
|
# File 'app/models/topic_timer.rb', line 107
def public_type?
!!self.class.public_types[self.status_type]
end
|
#publishing_to_category? ⇒ Boolean
121
122
123
|
# File 'app/models/topic_timer.rb', line 121
def publishing_to_category?
self.status_type.to_i == TopicTimer.types[:publish_to_category]
end
|
#runnable? ⇒ Boolean
115
116
117
118
119
|
# File 'app/models/topic_timer.rb', line 115
def runnable?
return false if deleted_at.present?
return false if execute_at > Time.zone.now
true
end
|
#status_type_name ⇒ Object
58
59
60
|
# File 'app/models/topic_timer.rb', line 58
def status_type_name
self.class.types[status_type]
end
|