Module: MnoEnterprise::Concerns::Models::Ability
- Extended by:
- ActiveSupport::Concern
- Included in:
- Ability
- Defined in:
- lib/mno_enterprise/concerns/models/ability.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #impac_abilities(user) ⇒ Object
-
#initialize(user) ⇒ Object
Instance methods ==================================================================.
Instance Method Details
#impac_abilities(user) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/mno_enterprise/concerns/models/ability.rb', line 101 def impac_abilities(user) can :manage_impac, MnoEnterprise::Impac::Dashboard do |dhb| dhb.organizations.any? && dhb.organizations.all? do |org| !!user.role(org) && ['Super Admin', 'Admin'].include?(user.role(org)) end end end |
#initialize(user) ⇒ Object
Instance methods
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 |
# File 'lib/mno_enterprise/concerns/models/ability.rb', line 22 def initialize(user) user ||= MnoEnterprise::User.new #=================================================== # Organization #=================================================== can :create, MnoEnterprise::Organization can :read, MnoEnterprise::Organization do |organization| !!user.role(organization) end can [:update, :destroy, :manage_billing], MnoEnterprise::Organization do |organization| user.role(organization) == 'Super Admin' end can [:upload, :purchase, :invite_member, :administrate, :manage_app_instances, :manage_teams], MnoEnterprise::Organization do |organization| ['Super Admin','Admin'].include? user.role(organization) end # To be updated can :sync_apps, MnoEnterprise::Organization do |organization| user.role(organization) end # To be updated can :check_apps_sync, MnoEnterprise::Organization do |organization| user.role(organization) end #=================================================== # AppInstance #=================================================== can :access, MnoEnterprise::AppInstance do |app_instance| !!user.role(app_instance.owner) && ( ['Super Admin','Admin'].include?(user.role(app_instance.owner)) || user.teams.empty? || user.teams.map(&:app_instances).compact.flatten.map(&:id).include?(app_instance.id) ) end #=================================================== # Impac #=================================================== impac_abilities(user) # Define abilities for the passed in user here. For example: # # user ||= User.new # guest user (not logged in) # if user.admin? # can :manage, :all # else # can :read, :all # end # # The first argument to `can` is the action you are giving the user # permission to do. # If you pass :manage it will apply to every action. Other common actions # here are :read, :create, :update and :destroy. # # The second argument is the resource the user can perform the action on. # If you pass :all it will apply to every resource. Otherwise pass a Ruby # class of the resource. # # The third argument is an optional hash of conditions to further filter the # objects. # For example, here the user can only update published articles. # # can :update, Article, :published => true # # See the wiki for details: # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities end |