Class: Ish::EmailContext

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/ish/email_context.rb

Overview

Send a single email

Constant Summary collapse

PAGE_PARAM_NAME =
'email_contexts_page'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tidObject (readonly)

For tracking / utm



77
78
79
# File 'lib/ish/email_context.rb', line 77

def tid
  @tid
end

Class Method Details

.from_email_listObject



65
66
67
# File 'lib/ish/email_context.rb', line 65

def self.from_email_list
  Ish::EmailCampaign.from_email_list
end

.notsentObject



55
# File 'lib/ish/email_context.rb', line 55

def self.notsent; new.notsent; end

.scheduledObject



62
# File 'lib/ish/email_context.rb', line 62

def self.scheduled; new.scheduled; end

Instance Method Details

#bodyObject



22
23
24
25
26
27
28
# File 'lib/ish/email_context.rb', line 22

def body
  if self[:body].presence
    return self[:body]
  else
    return tmpl.body
  end
end

#get_bindingObject



79
80
81
82
# File 'lib/ish/email_context.rb', line 79

def get_binding
  @lead = lead()
  binding()
end

#leadObject



70
# File 'lib/ish/email_context.rb', line 70

def lead; Lead.find( lead_id ); end

#notsentObject



52
53
54
# File 'lib/ish/email_context.rb', line 52

def notsent
  Ish::EmailContext.where( sent_at: nil )
end

#preview_strObject



13
14
15
16
17
18
19
# File 'lib/ish/email_context.rb', line 13

def preview_str
  if self[:preview_str].presence
    return self[:preview_str]
  else
    return tmpl.preview_str
  end
end

#schObject



44
# File 'lib/ish/email_context.rb', line 44

def sch; scheduled_email_action; end

#scheduledObject



58
59
60
61
# File 'lib/ish/email_context.rb', line 58

def scheduled
  # or({ :send_at.lte => Time.now }, { :send_at => nil }) ## This won't work b/c I need draft state!
  Ish::EmailContext.where({ :send_at.lte => Time.now  })
end

#tmplObject



41
# File 'lib/ish/email_context.rb', line 41

def tmpl; email_template; end

#to_emailObject

@TODO: remove, just use the lead. vp 2023-03-27



71
# File 'lib/ish/email_context.rb', line 71

def to_email; lead[:email]; end