Class: RailsMailerSandbox::Message
- Inherits:
-
Object
- Object
- RailsMailerSandbox::Message
- Defined in:
- lib/rails_mailer_sandbox.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#bcc ⇒ Object
readonly
Returns the value of attribute bcc.
-
#cc ⇒ Object
readonly
Returns the value of attribute cc.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#html_part ⇒ Object
readonly
Returns the value of attribute html_part.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#raw_source ⇒ Object
readonly
Returns the value of attribute raw_source.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#text_part ⇒ Object
readonly
Returns the value of attribute text_part.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(mail, id: SecureRandom.uuid) ⇒ Message
constructor
A new instance of Message.
- #matches?(query) ⇒ Boolean
- #preview ⇒ Object
- #recipients ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(mail, id: SecureRandom.uuid) ⇒ Message
Returns a new instance of Message.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rails_mailer_sandbox.rb', line 29 def initialize(mail, id: SecureRandom.uuid) @id = id @date = mail.date || Time.now @from = Array(mail.from) @to = Array(mail.to) @cc = Array(mail.cc) @bcc = Array(mail.bcc) @subject = mail.subject.to_s @attachments = [] extract_parts(mail) @raw_source = mail.to_s @raw_source = "Bcc: #{@bcc.join(', ').gsub(/[\r\n]/, '')}\r\n#{@raw_source}" unless @bcc.empty? || @raw_source.match?(/^Bcc:/i) end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def @attachments end |
#bcc ⇒ Object (readonly)
Returns the value of attribute bcc.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def bcc @bcc end |
#cc ⇒ Object (readonly)
Returns the value of attribute cc.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def cc @cc end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def date @date end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def from @from end |
#html_part ⇒ Object (readonly)
Returns the value of attribute html_part.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def html_part @html_part end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def id @id end |
#raw_source ⇒ Object (readonly)
Returns the value of attribute raw_source.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def raw_source @raw_source end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def subject @subject end |
#text_part ⇒ Object (readonly)
Returns the value of attribute text_part.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def text_part @text_part end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
26 27 28 |
# File 'lib/rails_mailer_sandbox.rb', line 26 def to @to end |
Instance Method Details
#matches?(query) ⇒ Boolean
55 56 57 |
# File 'lib/rails_mailer_sandbox.rb', line 55 def matches?(query) query.empty? || [subject, *from, *recipients, text_part.to_s].any? { |value| value.downcase.include?(query) } end |
#preview ⇒ Object
47 48 49 |
# File 'lib/rails_mailer_sandbox.rb', line 47 def preview text_part.to_s.gsub(/\s+/, " ").strip[0, 140] end |
#recipients ⇒ Object
43 44 45 |
# File 'lib/rails_mailer_sandbox.rb', line 43 def recipients to + cc + bcc end |
#size ⇒ Object
51 52 53 |
# File 'lib/rails_mailer_sandbox.rb', line 51 def size raw_source.bytesize end |