Permalink
Browse files

wicz is smart. better way to do role comparison

  • Loading branch information...
1 parent 5a83453 commit a961afd6e0e59f4d2059520f1c5fd4bb808a5c4a @seejee seejee committed Mar 18, 2012
Showing with 2 additions and 11 deletions.
  1. +1 −1 app/decorators/person_decorator.rb
  2. +1 −10 app/models/course_membership.rb
View
2 app/decorators/person_decorator.rb
@@ -8,7 +8,7 @@ def initialize(person)
end
def has_role?(role, course)
- membership = course.course_memberships.for_person(self).first
+ membership = course.course_memberships.for_person(@person).first
membership.has_role?(role) if membership
end
end
View
11 app/models/course_membership.rb
@@ -16,16 +16,7 @@ def person
end
def has_role?(has_role)
- #TODO: turn ROLES into a hash
-
- case has_role
- when :instructor
- role == "Instructor"
- when :student
- role == "Student"
- when :mentor
- role == "Mentor"
- end
+ has_role.to_s.capitalize == role.capitalize
end
private

0 comments on commit a961afd

Please sign in to comment.