Module: WithResponsibleModerator
- Extended by:
- ActiveSupport::Concern
- Included in:
- Discussion
- Defined in:
- app/models/concerns/with_responsible_moderator.rb
Constant Summary collapse
- MODERATOR_MAX_RESPONSIBLE_TIME =
45.minutes
Instance Method Summary collapse
- #any_responsible? ⇒ Boolean
- #can_toggle_responsible?(user) ⇒ Boolean
- #current_responsible_visible_for?(user) ⇒ Boolean
- #no_current_responsible? ⇒ Boolean
- #responsible?(moderator) ⇒ Boolean
- #toggle_responsible!(moderator) ⇒ Object
Instance Method Details
#any_responsible? ⇒ Boolean
14 15 16 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 14 def any_responsible? responsible_moderator_at.present? && (responsible_moderator_at + MODERATOR_MAX_RESPONSIBLE_TIME).future? end |
#can_toggle_responsible?(user) ⇒ Boolean
30 31 32 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 30 def can_toggle_responsible?(user) can_have_responsible? && user_can_be_responsible?(user) end |
#current_responsible_visible_for?(user) ⇒ Boolean
26 27 28 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 26 def current_responsible_visible_for?(user) user&.moderator_here? && any_responsible? end |
#no_current_responsible? ⇒ Boolean
18 19 20 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 18 def no_current_responsible? !any_responsible? end |
#responsible?(moderator) ⇒ Boolean
22 23 24 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 22 def responsible?(moderator) any_responsible? && responsible_moderator_by == moderator end |
#toggle_responsible!(moderator) ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/models/concerns/with_responsible_moderator.rb', line 6 def toggle_responsible!(moderator) if responsible?(moderator) no_responsible! elsif no_current_responsible? responsible! moderator end end |