Class: Message
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Message
- Includes:
- Statesman::Adapters::ActiveRecordQueries
- Defined in:
- app/models/message.rb
Instance Attribute Summary collapse
-
#recipient ⇒ Object
Returns the value of attribute recipient.
Instance Method Summary collapse
- #read ⇒ Object
- #read? ⇒ Boolean
- #send_notification ⇒ Object
- #set_receiver ⇒ Object
- #state_machine ⇒ Object
Instance Attribute Details
#recipient ⇒ Object
Returns the value of attribute recipient.
16 17 18 |
# File 'app/models/message.rb', line 16 def recipient @recipient end |
Instance Method Details
#read ⇒ Object
54 55 56 |
# File 'app/models/message.rb', line 54 def read transition_to!(:read) end |
#read? ⇒ Boolean
58 59 60 61 |
# File 'app/models/message.rb', line 58 def read? return true if current_state == 'read' false end |
#send_notification ⇒ Object
50 51 52 |
# File 'app/models/message.rb', line 50 def send_notification Notifier.(id).deliver_later if receiver.try(:email).present? end |
#set_receiver ⇒ Object
44 45 46 47 48 |
# File 'app/models/message.rb', line 44 def set_receiver if recipient self.receiver = User.where(username: recipient).first end end |
#state_machine ⇒ Object
37 38 39 |
# File 'app/models/message.rb', line 37 def state_machine @state_machine ||= MessageStateMachine.new(self, transition_class: MessageTransition) end |