Class: Iqvoc::Ability
- Inherits:
-
Object
- Object
- Iqvoc::Ability
- Includes:
- CanCan::Ability
- Defined in:
- lib/iqvoc/ability.rb
Constant Summary collapse
- @@if_published =
lambda { |o| o.published? }
Instance Method Summary collapse
-
#initialize(user = nil) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user = nil) ⇒ Ability
Returns a new instance of Ability.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/iqvoc/ability.rb', line 7 def initialize(user = nil) can :read, Iqvoc::Concept.root_class.instance can :read, ::Collection::Base can :read, [::Concept::Base, ::Label::Base], &@@if_published # static pages can :read, :help if user # Every logged in user ... can :use, :dashboard can :destroy, UserSession if user.owns_role?(:editor) || user.owns_role?(:publisher) || user.owns_role?(:administrator) # Editors and above ... can :manage, ::Collection::Base can :read, [::Concept::Base, ::Label::Base] can :create, [::Concept::Base, ::Label::Base] can [:update, :destroy, :unlock], [::Concept::Base, ::Label::Base], :locked_by => user.id, :published_at => nil can :lock, [::Concept::Base, ::Label::Base], :locked_by => nil, :published_at => nil can [:check_consistency, :send_to_review], [::Concept::Base, ::Label::Base], :published_at => nil can :branch, [::Concept::Base, ::Label::Base], &@@if_published end if user.owns_role?(:publisher) || user.owns_role?(:administrator) # Publishers and above ... can :merge, [::Concept::Base, ::Label::Base], :published_at => nil end if user.owns_role?(:administrator) # Admins ... can [:update, :destroy, :unlock], [::Concept::Base, ::Label::Base], :published_at => nil # Mustn't be locked by myself can :manage, User can :manage, Iqvoc.config can :full_export, ::Concept::Base can :import, ::Concept::Base end else # no user can :create, UserSession end end |