Class: Rsvp::Response
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rsvp::Response
- Defined in:
- app/models/rsvp/response.rb
Instance Method Summary collapse
- #is_no? ⇒ Boolean
- #is_yes? ⇒ Boolean
- #validate_email_if_entered ⇒ Object
- #validate_total_attending ⇒ Object
Instance Method Details
#is_no? ⇒ 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
22 23 24 |
# File 'app/models/rsvp/response.rb', line 22 def is_yes? total_attending.to_i > 0 end |
#validate_email_if_entered ⇒ Object
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_attending ⇒ Object
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 |