Module: WithMessages
- Included in:
- Assignment
- Defined in:
- app/models/concerns/with_messages.rb
Instance Method Summary collapse
- #build_message(body) ⇒ Object
- #has_messages? ⇒ Boolean
- #pending_messages? ⇒ Boolean
- #receive_answer!(answer) ⇒ Object
- #send_question!(question) ⇒ Object
Instance Method Details
#build_message(body) ⇒ Object
11 12 13 |
# File 'app/models/concerns/with_messages.rb', line 11 def (body) .build({date: Time.current, submission_id: submission_id}.merge(body)) end |
#has_messages? ⇒ Boolean
15 16 17 |
# File 'app/models/concerns/with_messages.rb', line 15 def .exists? end |
#pending_messages? ⇒ Boolean
19 20 21 |
# File 'app/models/concerns/with_messages.rb', line 19 def .exists? read: false end |
#receive_answer!(answer) ⇒ Object
2 3 4 |
# File 'app/models/concerns/with_messages.rb', line 2 def receive_answer!(answer) (answer).save! end |
#send_question!(question) ⇒ Object
6 7 8 9 |
# File 'app/models/concerns/with_messages.rb', line 6 def send_question!(question) = question.merge(sender: submitter, read: true) .save_and_notify! end |