Module: Pageflow::Roles
- Defined in:
- app/models/pageflow/roles.rb
Class Method Summary collapse
Class Method Details
.at_least(role_uncasted) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/pageflow/roles.rb', line 5 def at_least(role_uncasted) role = role_uncasted.to_sym if role == :member %w(member previewer editor publisher manager) elsif role == :previewer %w(previewer editor publisher manager) elsif role == :editor %w(editor publisher manager) elsif role == :publisher %w(publisher manager) elsif role == :manager %w(manager) end end |
.high(user, entry) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/pageflow/roles.rb', line 20 def high(user, entry) roles = [:none, :member, :previewer, :editor, :publisher, :manager] account_membership = Membership.where(user: user, entity: entry.account).first account_role = account_membership ? account_membership.role : :none if user.entries.include?(entry) entry_role = Membership.where(user: user, entity: entry).first.role else entry_role = :none end if roles.find_index(account_role.to_sym) > roles.find_index(entry_role.to_sym) account_role.to_sym else entry_role.to_sym end end |