From ca92fcd9de5863532bd54cc1b601883c8f1ad37c Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Wed, 5 Sep 2018 14:45:02 +0100 Subject: Allow the TemplateFinder to handle licenses as well --- lib/api/templates.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/api/templates.rb') diff --git a/lib/api/templates.rb b/lib/api/templates.rb index 5d817d36032..7bf0e0f5934 100644 --- a/lib/api/templates.rb +++ b/lib/api/templates.rb @@ -33,7 +33,7 @@ module API popular = declared(params)[:popular] popular = to_boolean(popular) if popular.present? - templates = LicenseTemplateFinder.new(popular: popular).execute + templates = TemplateFinder.build(:licenses, popular: popular).execute present paginate(::Kaminari.paginate_array(templates)), with: ::API::Entities::License end @@ -46,7 +46,7 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do - templates = LicenseTemplateFinder.new.execute + templates = TemplateFinder.build(:licenses).execute template = templates.find { |template| template.key == params[:name] } not_found!('License') unless template.present? @@ -82,7 +82,7 @@ module API requires :name, type: String, desc: 'The name of the template' end get "templates/#{template_type}/:name" do - finder = TemplateFinder.new(template_type, name: declared(params)[:name]) + finder = TemplateFinder.build(template_type, name: declared(params)[:name]) new_template = finder.execute render_response(template_type, new_template) -- cgit v1.2.1