Class: Rsvp::Response

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/rsvp/response.rb

Instance Method Summary collapse

Instance Method Details

#is_no?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/rsvp/response.rb', line 26

def is_no?
  total_attending.to_i == 0 && !total_attending.nil?
end

#is_yes?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/rsvp/response.rb', line 22

def is_yes?
  total_attending.to_i > 0
end

#validate_email_if_enteredObject



16
17
18
19
20
# File 'app/models/rsvp/response.rb', line 16

def validate_email_if_entered
  if email.present? && !email.match(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i)
    errors.add(:email, "is invalid")
  end
end

#validate_total_attendingObject



10
11
12
13
14
# File 'app/models/rsvp/response.rb', line 10

def validate_total_attending
  if invitation.total_invited < total_attending.to_i
    errors.add(:total_attending, "cannot be greater than total invited")
  end
end