Welcome to mirror list, hosted at ThFree Co, Russian Federation.

params.rb « links « releases « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 124ab333bbce5cc92ebab937f1d114e98d9d456b (plain)
1
2
3
4
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
# frozen_string_literal: true

module Releases
  module Links
    class Params
      def initialize(params)
        @params = params.with_indifferent_access
      end

      def allowed_params
        @allowed_params ||= params.slice(:name, :url, :link_type).tap do |hash|
          hash[:filepath] = filepath if provided_filepath?
        end
      end

      private

      attr_reader :params

      def provided_filepath?
        params.key?(:direct_asset_path) || params.key?(:filepath)
      end

      def filepath
        params[:direct_asset_path] || params[:filepath]
      end
    end
  end
end