class Webspicy::Tester::Fakesendgrid::Email

Attributes

data[R]

Public Class Methods

new(data) click to toggle source
# File lib/webspicy/tester/fakesendgrid/email.rb, line 6
def initialize(data)
  @data = data
end

Public Instance Methods

bcc() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/webspicy/tester/fakesendgrid/email.rb, line 41
def subject
  @subject ||= data["subject"]
end
to() click to toggle source
# 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