Class: LicenseTemplateFinder
- Inherits:
-
Object
- Object
- LicenseTemplateFinder
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/finders/license_template_finder.rb
Overview
LicenseTemplateFinder
Used to find license templates, which may come from a variety of external sources
Params can be any of the following:
popular: boolean. When set to true, only "popular" licenses are shown. When
false, all licenses except popular ones are shown. When nil (the
default), *all* licenses will be shown.
name: string. If set, return a single license matching that name (or nil)
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, params = {}) ⇒ LicenseTemplateFinder
constructor
A new instance of LicenseTemplateFinder.
- #template_names ⇒ Object
Constructor Details
#initialize(project, params = {}) ⇒ LicenseTemplateFinder
Returns a new instance of LicenseTemplateFinder.
18 19 20 21 |
# File 'app/finders/license_template_finder.rb', line 18 def initialize(project, params = {}) @project = project @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
16 17 18 |
# File 'app/finders/license_template_finder.rb', line 16 def params @params end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
16 17 18 |
# File 'app/finders/license_template_finder.rb', line 16 def project @project end |
Instance Method Details
#execute ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/finders/license_template_finder.rb', line 23 def execute if params[:name] vendored_licenses.find { |template| template.key == params[:name] } else vendored_licenses end end |
#template_names ⇒ Object
31 32 33 |
# File 'app/finders/license_template_finder.rb', line 31 def template_names ::Gitlab::Template::BaseTemplate.template_names_by_category(vendored_licenses) end |