Class: Ish::EmailContext

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

Overview

Sends a single email

Constant Summary collapse

PAGE_PARAM_NAME =
'email_contexts_page'
FROM_EMAILS =
[
  'Infinite Shelter <[email protected]>',
  'Infinite Shelter <[email protected]>',
  'Victor Piousbox <[email protected]>',
  'Victor Piousbox <[email protected]>',
  'Victor Piousbox <[email protected]>',
  'Victor Piousbox <[email protected]>',
  'WasyaCo Consulting <[email protected]>',
  'WasyaCo Consulting <[email protected]>',
  'Victor Piousbox <[email protected]>',
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tidObject (readonly)

For tracking / utm



94
95
96
# File 'lib/ish/email_context.rb', line 94

def tid
  @tid
end

Class Method Details

.from_email_listObject



38
39
40
# File 'lib/ish/email_context.rb', line 38

def self.from_email_list
  [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
end

.scheduledObject



67
68
69
# File 'lib/ish/email_context.rb', line 67

def self.scheduled
  new.scheduled
end

.unsentObject



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

def self.unsent
  new.unsent
end

Instance Method Details

#get_bindingObject



96
97
98
99
# File 'lib/ish/email_context.rb', line 96

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

#leadObject



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

def lead
  Lead.find lead_id
end

#preview_strObject



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

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

#scheduledObject



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

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

#slugObject

@TODO: probably rename it to slug



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

field :slug

#tmplObject



48
49
50
# File 'lib/ish/email_context.rb', line 48

def tmpl
  email_template
end

#to_emailObject

@deprecated: use self.lead



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

field :to_email

#unsentObject



63
64
65
# File 'lib/ish/email_context.rb', line 63

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