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.
15 16 17 |
# File 'app/models/message.rb', line 15 def recipient @recipient end |
Instance Method Details
#read ⇒ Object
53 54 55 |
# File 'app/models/message.rb', line 53 def read transition_to!(:read) end |
#read? ⇒ Boolean
57 58 59 60 |
# File 'app/models/message.rb', line 57 def read? return true if current_state == 'read' false end |
#send_notification ⇒ Object
49 50 51 |
# File 'app/models/message.rb', line 49 def send_notification Notifier.(id).deliver_later if receiver.try(:email).present? end |
#set_receiver ⇒ Object
43 44 45 46 47 |
# File 'app/models/message.rb', line 43 def set_receiver if recipient self.receiver = User.where(username: recipient).first end end |
#state_machine ⇒ Object
36 37 38 |
# File 'app/models/message.rb', line 36 def state_machine @state_machine ||= MessageStateMachine.new(self, transition_class: MessageTransition) end |