Sha256: a8c0ad8d4605137c00ea084f79e7888115a2823d7568dcc99b8250307d6eb6c7
Contents?: true
Size: 508 Bytes
Versions: 4
Compression:
Stored size: 508 Bytes
Contents
class PageRole < ActiveRecord::Base # Relationships belongs_to :required_role, :class_name => 'Role' belongs_to :excluded_role, :class_name => 'Role' # Scopes scope :viewable_by, lambda { |user| where(:required_role_id => user.role_ids) } scope :not_viewable_by, lambda { |user| where(:excluded_role_id => user.role_ids) } class << self def viewable_page_ids_for(user) PageRole.viewable_by(user).map(&:page_id) - PageRole.not_viewable_by(user).map(&:page_id) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
page_engine-0.0.4 | app/models/page_role.rb |
page_engine-0.0.3 | app/models/page_role.rb |
page_engine-0.0.2 | app/models/page_role.rb |
page_engine-0.0.1 | app/models/page_role.rb |