Class: Blazer::Check

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/blazer/check.rb

Instance Method Summary collapse

Instance Method Details

#split_emailsObject



7
8
9
# File 'app/models/blazer/check.rb', line 7

def split_emails
  emails.to_s.split(",").map(&:strip)
end

#update_state(rows, error) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/blazer/check.rb', line 11

def update_state(rows, error)
  self.state =
    if error
      "error"
    elsif rows.any?
      "failing"
    else
      "passing"
    end

  # do not notify on creation, except when not passing
  if (state_was || state != "passing") && state != state_was && emails.present?
    Blazer::CheckMailer.state_change(self, state, state_was, rows.size, error).deliver_later
  end
  save! if changed?
end