gitlab-ce/lib/api
Robert Speicher e71cd7a300 Merge branch 'refactor/add-policies' into 'master'
Refactor ability.rb into Policies

## What does this MR do?
Factors out `ability.rb` into a new abstraction - the "policy" (stored in `app/policies`). A policy is a class named `#{class_name}Policy` (looked up automatically as needed) that implements `rules` as follows:

``` ruby
class ThingPolicy < BasePolicy
  def rules
    @user # this is a user to determine abilities for, optionally nil in the anonymous case
    @subject # this is the subject of the ability, guaranteed to be an instance of `Thing`
    can! :some_ability # grant the :some_ability permission
    cannot! :some_ability # ensure that :some_ability is not allowed. this overrides any `can!` that is called before or after
    delegate! @subject.other_thing # merge the abilities (can!) and prohibitions (cannot!) from `@subject.other_thing`
    can? :some_ability # test whether, so far, :some_ability is allowed
  end

  def anonymous_rules
    # optional. if not implemented `rules` is called where `@user` is nil. otherwise this method is called when `@user` is nil.
  end
end
```

See merge request !5796
2016-08-31 20:53:40 +00:00
..
helpers New AccessRequests API endpoints for Group & Project 2016-08-10 19:07:05 +02:00
access_requests.rb Improve the performance of the GET /:sources/:id/{access_requests,members} API endpoints 2016-08-10 19:07:05 +02:00
api.rb Add BroadcastMessage API implementation 2016-08-31 17:03:18 -03:00
api_guard.rb
award_emoji.rb prevent authored awardable thumbs votes 2016-08-28 18:15:55 +01:00
branches.rb Fix failing tests relating to backporting ee!581. 2016-08-16 13:42:34 +05:30
broadcast_messages.rb Add BroadcastMessage API implementation 2016-08-31 17:03:18 -03:00
builds.rb Incorporate feedback 2016-08-18 21:10:53 +02:00
commit_statuses.rb Reverse ref and sha in args and rename pipeline to pipeline_for 2016-08-11 17:26:04 +08:00
commits.rb switch from diff_file_collection to diffs 2016-08-03 07:00:20 +02:00
deploy_keys.rb Namespace EnableDeployKeyService under Projects 2016-08-08 20:59:51 +02:00
deployments.rb Add deployment endpoints 2016-08-18 21:10:52 +02:00
entities.rb Add BroadcastMessage API implementation 2016-08-31 17:03:18 -03:00
environments.rb Minor fixes in the Env API endpoints 2016-08-01 08:42:09 +02:00
files.rb
groups.rb use a nil subject when we want to check global abilities 2016-08-30 11:39:22 -07:00
helpers.rb use a nil subject when we want to check global abilities 2016-08-30 11:39:22 -07:00
internal.rb Add two factor recovery endpoint to internal API 2016-08-24 17:50:57 -05:00
issues.rb API: Expose issue#confidential 2016-08-31 09:20:04 +02:00
keys.rb
labels.rb
license_templates.rb
members.rb Add expiration date to group memberships 2016-08-18 21:09:17 +01:00
merge_request_diffs.rb Add single merge request diff API endpoint 2016-08-12 14:44:49 +03:00
merge_requests.rb Replace parse_boolean with to_boolean 2016-07-20 08:55:44 +02:00
milestones.rb
namespaces.rb
notes.rb
pipelines.rb Add endpoints for pipelines 2016-08-18 16:56:39 +02:00
project_hooks.rb api: expose wiki_page_events project hook field in the API 2016-08-24 10:33:51 -04:00
project_snippets.rb
projects.rb Renamed `enable_lfs` to `lfs_enabled` for the Project field, and related fixes. 2016-08-30 17:17:45 -05:00
repositories.rb
runners.rb
services.rb
session.rb Small refactor and syntax fixes. 2016-08-18 16:47:26 -05:00
settings.rb
sidekiq_metrics.rb
subscriptions.rb
system_hooks.rb
tags.rb
templates.rb Load issues and merge requests templates from repository 2016-08-16 15:50:17 -03:00
todos.rb Recover usage of Todos counter cache 2016-08-12 18:21:36 +02:00
triggers.rb
users.rb Don't expose a user's private token in the `/api/v3/user` API. 2016-08-31 12:33:24 +05:30
variables.rb