Class: MessageDraft

Inherits:
Message show all
Defined in:
app/models/message_draft.rb

Overview

Note:

drafts are essentially messages with an implied folder (drafts), and if a reply, an implied message

Models Message draft

Constant Summary

Constants inherited from Message

Message::MAX_SINGLE_FILE_SIZE_MB, Message::MAX_TOTAL_FILE_SIZE_MB

Instance Attribute Summary collapse

Attributes inherited from Message

#attachment, #attachments, #body, #category, #id, #proxy_sender_name, #read_receipt, #recipient_id, #recipient_name, #sender_id, #sender_name, #sent_date, #subject, #triage_group_name

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

Methods inherited from Message

#<=>, #as_reply, #initialize, #reply?

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, #initialize, max_per_page, per_page, sortable_attributes

Constructor Details

This class inherits a constructor from Message

Instance Attribute Details

#has_messageBoolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/message_draft.rb', line 10

class MessageDraft < Message
  validate :check_as_replydraft, if: proc { reply? }
  validate :check_as_draft, unless: proc { reply? }
  attr_accessor :original_attributes

  attribute :has_message, Boolean

  def message?
    has_message
  end

  private

  def check_as_replydraft
    errors.add(:base, 'This draft requires a reply-to message.') unless message?
  end

  def check_as_draft
    errors.add(:base, 'This draft cannot have a reply-to message') if message?
  end
end

#original_attributesObject

Returns the value of attribute original_attributes.



13
14
15
# File 'app/models/message_draft.rb', line 13

def original_attributes
  @original_attributes
end

Instance Method Details

#message?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/message_draft.rb', line 17

def message?
  has_message
end