class Ability
  include Dunlop::Ability
  add_allowed_authorization_classes 'SourceFile::MySource'

  def setup_abilities
    setup_dunlop_abilities
    if user.my_domain.present?
      can :manage, User, User.for_domain(user.my_domain) do |domain_user|
        user.my_domain == domain_user.my_domain and user.role_names_admin.include?('manage-domain-User')
      end
    end
  end
end
