lib/role_on.rb in darkhelmet-role_on-0.2.3 vs lib/role_on.rb in darkhelmet-role_on-0.2.4
- old
+ new
@@ -31,16 +31,11 @@
alias :has_roles? :has_role?
end
module RoleOnUserClassMethods
def helper_for(role,name = role.to_s.pluralize)
- named_scope(name) do
- { :conditions => ['role_id = ?', Role[role].id], :joins => :roles }
- end
-
- named_scope("non_#{name}") do
- { :conditions => [ 'roles.id is ? or roles.id != ?', nil, Role[role].id ], :joins => :roles }
- end
+ named_scope(name, lambda { { :conditions => ['role_id = ?', Role[role].id], :joins => :roles } })
+ named_scope("non_#{name}", lambda { { :conditions => [ 'roles.id is ? or roles.id != ?', nil, Role[role].id ], :joins => :roles } })
end
end
def self.included(klass)
if User == klass