Created
February 27, 2014 20:42
-
-
Save jmccartie/9259126 to your computer and use it in GitHub Desktop.
Oh lordy, this is ripe for a refactor, but I can't quite see it...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case service_time.relation_to_sunday | |
when "Current" | |
previous_sunday | |
when "Before" | |
if date.wday == service_time.day_of_week | |
#use date and time | |
actual_service_time = service_time_with_offset(service_time, date, true) | |
if time >= actual_service_time | |
return upcoming_sunday | |
else | |
return previous_sunday | |
end | |
elsif date.wday > service_time.day_of_week | |
return upcoming_sunday | |
else | |
return previous_sunday | |
end | |
when "After" | |
if date.wday == service_time.day_of_week | |
#use date and time | |
actual_service_time = service_time_with_offset(service_time, date, true) | |
if time <= actual_service_time | |
return previous_sunday | |
else | |
return upcoming_sunday | |
end | |
elsif date.wday < service_time.day_of_week | |
return previous_sunday | |
else | |
if church.service_times.where(relation_to_sunday: "Current").empty? | |
return previous_sunday | |
else | |
return upcoming_sunday | |
end | |
end | |
end |
Person.update_all(plan_permissions: 5)
That should do it!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could become :
Which you could maybe make a method to be reusable?