Class: Conschedule::Schedule
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Conschedule::Schedule
- Defined in:
- app/models/conschedule/schedule.rb
Instance Method Summary collapse
- #cancelled? ⇒ Boolean
- #display_action? ⇒ Boolean
- #full_name ⇒ Object
- #send_cancel_email ⇒ Object
- #send_confirmation_email ⇒ Object
- #slot_date_time(version, period) ⇒ Object
- #status_changed? ⇒ Boolean
- #validate_to_address ⇒ Object
Instance Method Details
#cancelled? ⇒ Boolean
42 43 44 |
# File 'app/models/conschedule/schedule.rb', line 42 def cancelled? status == "cancelled" end |
#display_action? ⇒ Boolean
46 47 48 49 50 51 52 53 54 |
# File 'app/models/conschedule/schedule.rb', line 46 def display_action? if status == "cancelled" return false else slot_start_time = self.slot_date_time("app","start") current_time = Time.now.in_time_zone(app_time_zone) return current_time > slot_start_time ? false : true end end |
#full_name ⇒ Object
13 14 15 |
# File 'app/models/conschedule/schedule.rb', line 13 def full_name [first_name,last_name].compact.join(" ") end |
#send_cancel_email ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/models/conschedule/schedule.rb', line 24 def send_cancel_email if status_changed? SchedulesMailer.send_cancel_email_user(self).deliver end if Conschedule.send_cancel_mail && validate_to_address SchedulesMailer.send_cancel_email_owner(self).deliver end end |
#send_confirmation_email ⇒ Object
17 18 19 20 21 22 |
# File 'app/models/conschedule/schedule.rb', line 17 def send_confirmation_email SchedulesMailer.send_confirmation_email_user(self).deliver if Conschedule.send_confirmation_mail && validate_to_address SchedulesMailer.send_confirmation_email_owner(self).deliver end end |
#slot_date_time(version, period) ⇒ Object
56 57 58 59 |
# File 'app/models/conschedule/schedule.rb', line 56 def slot_date_time(version,period) tz = version == "app" ? app_time_zone : user_time_zone period == "start" ? slot_start_time.in_time_zone(tz) : slot_end_time.in_time_zone(tz) end |
#status_changed? ⇒ Boolean
33 34 35 |
# File 'app/models/conschedule/schedule.rb', line 33 def status_changed? changed_attributes.has_key?("status") && changed_attributes["status"] == "active" end |
#validate_to_address ⇒ Object
37 38 39 40 |
# File 'app/models/conschedule/schedule.rb', line 37 def validate_to_address return false if Conschedule.to_address.downcase =~ /please-change-me/ return true end |