Sha256: 13b1d1e43fa539dd66ae71b308e5938f2cb87111a9219e196f99a9fcc3c8bf00

Contents?: true

Size: 472 Bytes

Versions: 5

Compression:

Stored size: 472 Bytes

Contents

module EnjuNii
  class Ability
    include CanCan::Ability

    def initialize(user, ip_address = '0.0.0.0')
      case user.try(:role).try(:name)
      when 'Administrator'
        can [:read, :create, :update], NiiType
        can [:destroy, :delete], NiiType do |nii_type|
          true unless nii_type.manifestations.exists?
        end if LibraryGroup.site_config.network_access_allowed?(ip_address)
      else
        can :read, NiiType
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
enju_nii-0.1.1 app/models/enju_nii/ability.rb
enju_nii-0.1.0 app/models/enju_nii/ability.rb
enju_nii-0.1.0.pre14 app/models/enju_nii/ability.rb
enju_nii-0.1.0.pre13 app/models/enju_nii/ability.rb
enju_nii-0.1.0.pre12 app/models/enju_nii/ability.rb