Class: EnjuCirculation::Ability
- Inherits:
-
Object
- Object
- EnjuCirculation::Ability
- Includes:
- CanCan::Ability
- Defined in:
- app/models/enju_circulation/ability.rb
Instance Method Summary collapse
-
#initialize(user, ip_address = nil) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user, ip_address = nil) ⇒ Ability
Returns a new instance of Ability.
5 6 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/models/enju_circulation/ability.rb', line 5 def initialize(user, ip_address = nil) case user.try(:role).try(:name) when 'Administrator' can [:destroy, :delete], Manifestation do |manifestation| manifestation.items.empty? and !manifestation.series_master? and !manifestation.is_reserved? end can [:destroy, :delete], Item do |item| true if item.removable? end can :manage, [ Basket, CarrierTypeHasCheckoutType, CheckedItem, Checkin, CheckoutStatHasManifestation, CheckoutStatHasUser, Demand, ItemHasUseRestriction, ManifestationCheckoutStat, ManifestationReserveStat, ReserveStatHasManifestation, ReserveStatHasUser, UserCheckoutStat, UserGroupHasCheckoutType, UserReserveStat ] can [:read, :create, :update], CheckoutType can [:destroy, :delete], CheckoutType do |checkout_type| true if checkout_type.items.empty? end can [:read, :create, :update, :remove_all], Checkout can [:destroy, :delete], Checkout do |checkout| checkout.checkin end can [:read, :create, :update], Reserve can [:destroy, :delete], Reserve do |reserve| true unless reserve.retained? end can [:read, :update], [ CirculationStatus, LendingPolicy, UseRestriction ] can [:destroy, :delete], LendingPolicy when 'Librarian' can [:destroy, :delete], Item do |item| true if item.removable? end can [:destroy, :delete], Manifestation do |manifestation| manifestation.items.empty? and !manifestation.series_master? and !manifestation.is_reserved? end can :manage, [ Basket, CheckedItem, Checkin, Demand, ManifestationCheckoutStat, ManifestationReserveStat, Reserve ] can [:read, :create, :update, :remove_all], Checkout can [:destroy, :delete], Checkout do |checkout| checkout.checkin end can [:read, :create, :update], UserCheckoutStat can [:read, :create, :update], UserReserveStat can :read, [ CarrierTypeHasCheckoutType, CheckoutType, CheckoutStatHasManifestation, CheckoutStatHasUser, CirculationStatus, ItemHasUseRestriction, LendingPolicy, ReserveStatHasManifestation, ReserveStatHasUser, UseRestriction, UserGroupHasCheckoutType ] when 'User' can [:index, :create, :remove_all], Checkout can [:show, :update], Checkout do |checkout| checkout.user == user end can [:destroy, :delete], Checkout do |checkout| checkout.user == user && checkout.checkin end can :index, Reserve can :create, Reserve do |reserve| user.profile.user_number.try(:present?) end can [:show, :update, :destroy, :delete], Reserve do |reserve| reserve.user == user end can :read, [ CirculationStatus, ManifestationCheckoutStat, ManifestationReserveStat ] else can :index, Checkout can :read, [ CirculationStatus, ManifestationCheckoutStat, ManifestationReserveStat ] end end |