Sha256: 2f5e6f27d7a26aa714670bc07c9101ea45b2c89b6fae1828dc9b8d7ae7885a19

Contents?: true

Size: 1005 Bytes

Versions: 10

Compression:

Stored size: 1005 Bytes

Contents

require_relative '../url_builders/url_builder'

module Gitlab
  module Triage
    module Resource
      class Base
        attr_reader :resource, :net

        def initialize(new_resource, new_net)
          @resource = new_resource
          @net = new_net
        end

        private

        def network
          net[:network]
        end

        def url(params = {})
          UrlBuilders::UrlBuilder.new(
            net_opts.merge(params: { per_page: 100 }.merge(params))
          ).build
        end

        def net_opts
          {
            host_url: net[:host_url],
            api_version: net[:api_version],
            resource_type: self.class.name.demodulize.underscore.pluralize,
            source: source,
            source_id: resource[:"#{source.singularize}_id"]
          }
        end

        def source
          if resource[:project_id]
            'projects'
          elsif resource[:group_id]
            'groups'
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gitlab-triage-0.14.1 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.14.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.13.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.12.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.11.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.10.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.9.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.8.1 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.8.0 lib/gitlab/triage/resource/base.rb
gitlab-triage-0.7.0 lib/gitlab/triage/resource/base.rb