Sha256: eefb857ba9a5a0d1b067567fc7a791c16ddc4be0a6b991b90d315210acf0bd93

Contents?: true

Size: 784 Bytes

Versions: 46

Compression:

Stored size: 784 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    case user.try(:role).try(:name)
    when 'Administrator'
      can [:read, :create], EventCategory
      can [:update, :destroy], EventCategory do |event_category|
        !['unknown', 'closed'].include?(event_category.name)
      end
      can :manage, [
        Event,
        EventImportFile,
        Participate
      ]
      can :read, EventImportResult
    when 'Librarian'
      can :manage, [
        Event,
        EventImportFile,
        Participate
      ]
      can :read, [
        EventCategory,
        EventImportResult
      ]
    when 'User'
      can :read, [
        Event,
        EventCategory
      ]
    else
      can :read, [
        Event,
        EventCategory
      ]
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
enju_event-0.1.17.pre6 spec/dummy/app/models/ability.rb
enju_event-0.1.17.pre5 spec/dummy/app/models/ability.rb
enju_event-0.1.17.pre4 spec/dummy/app/models/ability.rb
enju_event-0.1.17.pre3 spec/dummy/app/models/ability.rb
enju_event-0.1.17.pre2 spec/dummy/app/models/ability.rb
enju_event-0.1.17.pre spec/dummy/app/models/ability.rb
enju_event-0.1.16 spec/dummy/app/models/ability.rb
enju_event-0.1.15 spec/dummy/app/models/ability.rb
enju_event-0.1.13 spec/dummy/app/models/ability.rb
enju_event-0.0.27 spec/dummy/app/models/ability.rb
enju_event-0.0.26 spec/dummy/app/models/ability.rb
enju_event-0.0.25 spec/dummy/app/models/ability.rb
enju_event-0.1.12 spec/dummy/app/models/ability.rb
enju_event-0.1.11 spec/dummy/app/models/ability.rb
enju_event-0.0.24 spec/dummy/app/models/ability.rb
enju_event-0.0.23 spec/dummy/app/models/ability.rb
enju_event-0.1.10 spec/dummy/app/models/ability.rb
enju_event-0.1.9 spec/dummy/app/models/ability.rb
enju_event-0.0.22 spec/dummy/app/models/ability.rb
enju_event-0.0.21 spec/dummy/app/models/ability.rb