Skip to content

Commit

Permalink
visibility decisions now correctly override those already defined
Browse files Browse the repository at this point in the history
  • Loading branch information
will-r committed Nov 15, 2009
1 parent 49f1c6f commit 3486da0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/grouped_model.rb
Expand Up @@ -15,6 +15,15 @@ def is_grouped(options={})
class_eval {
extend GroupedModel::GroupedClassMethods
include GroupedModel::GroupedInstanceMethods

def visible_to?(reader)
return true unless group
return false unless reader
return true if reader.is_user?
return true if reader.is_in?(group)
return false
end

}

belongs_to :group
Expand Down Expand Up @@ -58,18 +67,11 @@ def gives_group_to(associations)
end

module GroupedInstanceMethods

def visible?
!!group
end

def visible_to?(reader)
return true unless group
return false unless reader
return true if reader.is_user?
return true if reader.is_in?(group)
return false
end

def permitted_groups
[group]
end
Expand Down

0 comments on commit 3486da0

Please sign in to comment.