Class: Webspicy::Tester::Fakesendgrid::Email
- Inherits:
-
Object
- Object
- Webspicy::Tester::Fakesendgrid::Email
- Defined in:
- lib/webspicy/tester/fakesendgrid/email.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #bcc ⇒ Object
- #cc ⇒ Object
- #from ⇒ Object
- #headers ⇒ Object
-
#initialize(data) ⇒ Email
constructor
A new instance of Email.
- #subject ⇒ Object
- #to ⇒ Object
Constructor Details
#initialize(data) ⇒ Email
Returns a new instance of Email.
6 7 8 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 6 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 9 def data @data end |
Instance Method Details
#bcc ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 33 def bcc @bcc ||= data["personalizations"] .select{|h| h.key? "bcc" } .map{|(h)| h["bcc"] } .flatten .map{|(h)| h["email"] } end |
#cc ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 25 def cc @cc ||= data["personalizations"] .select{|h| h.key? "cc" } .map{|(h)| h["cc"] } .flatten .map{|(h)| h["email"] } end |
#from ⇒ Object
11 12 13 14 15 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 11 def from @from ||= data['from']['name'] ? "#{data['from']['name']} <#{data['from']['email']}>" : data['from']['email'] end |
#headers ⇒ Object
45 46 47 48 49 50 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 45 def headers @headers ||= data["headers"].reduce(OpenStruct.new){|acc, (key, value)| acc[key.downcase] = value acc } end |
#subject ⇒ Object
41 42 43 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 41 def subject @subject ||= data["subject"] end |
#to ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/webspicy/tester/fakesendgrid/email.rb', line 17 def to @to ||= data["personalizations"] .select{|h| h.key? "to" } .map{|(h)| h["to"] } .flatten .map{|(h)| h["email"] } end |