Class: EnjuNii::Ability
- Inherits:
-
Object
- Object
- EnjuNii::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/enju_nii/ability.rb
Instance Method Summary collapse
-
#initialize(user, ip_address = '0.0.0.0') ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user, ip_address = '0.0.0.0') ⇒ Ability
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/models/enju_nii/ability.rb', line 5 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 |