diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-12-19 14:15:58 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-01-31 16:51:17 +0100 |
commit | 084b7edb17d25a3d43526cca560569dd82c5c09d (patch) | |
tree | eff6234322aec4cb438d4751bb7adb1c19cfd5cc /lib/api/helpers/presentable.rb | |
parent | 9f67b886b2cf425329a4dc792e6c41cf571ab102 (diff) | |
download | gitlab-ce-084b7edb17d25a3d43526cca560569dd82c5c09d.tar.gz |
Do not expose trigger token when user should not see it
Diffstat (limited to 'lib/api/helpers/presentable.rb')
-rw-r--r-- | lib/api/helpers/presentable.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/api/helpers/presentable.rb b/lib/api/helpers/presentable.rb new file mode 100644 index 00000000000..973c2132efe --- /dev/null +++ b/lib/api/helpers/presentable.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module API + module Helpers + ## + # This module makes it possible to use `app/presenters` with + # Grape Entities. It instantiates model presenter and passes + # options defined in the API endpoint to the presenter itself. + # + # present object, with: Entities::Something, + # current_user: current_user, + # another_option: 'my options' + # + # Example above will make `current_user` and `another_option` + # values available in the subclass of `Gitlab::View::Presenter` + # thorough a separate method in the presenter. + # + # The model class needs to have `::Presentable` module mixed in + # if you want to use `API::Helpers::Presentable`. + # + module Presentable + extend ActiveSupport::Concern + + def initialize(object, options = {}) + super(object.present(options), options) + end + end + end +end |