class ApiProblemGenerator
Public Instance Methods
build_error_html()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 10 def build_error_html template "errors_view.html.erb", "app/views#{ns_path}errors/#{name}.html.erb" template "errors_controller.erb", "app/controllers#{ns_path}errors_controller.rb" end
build_http_error()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 5 def build_http_error template "api_problem_layout.jbuilder.erb", "app/views#{ns_path}api_problems/#{name}.jbuilder" template "api_problem_layout.xml.erb", "app/views#{ns_path}api_problems/#{name}.xml.erb" end
build_route()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 15 def build_route route "match '#{ns_path}#{name}' => '#{ns_class_name}errors##{name}', :via => :get, :as => :#{problem}" inject_into_class "app/controllers/#{ns_path}errors_controller.rb", "#{ns_class_name}ErrorsController".classify, "def #{name}\nend\n" end
Private Instance Methods
detail()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 40 def detail one["detail"] end
instance()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 44 def instance one["instance"] end
ns()
click to toggle source
Namespace
# File lib/generators/api_problem/api_problem_generator.rb, line 49 def ns one["ns"] end
ns_class_name()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 57 def ns_class_name ns ? "#{ns.classify}::" : "" end
ns_path()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 53 def ns_path ns ? "/#{ns}/" : "/" end
problem()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 61 def problem ns ? "#{ns}_#{name}" : "#{name}" end
problem_url()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 65 def problem_url "#{problem}_url" end
status()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 36 def status one["status"] ? Integer(one["status"]) : nil end
title()
click to toggle source
# File lib/generators/api_problem/api_problem_generator.rb, line 32 def title one["title"] end
type()
click to toggle source
User must specify that they don’t a type by setting type:false
# File lib/generators/api_problem/api_problem_generator.rb, line 22 def type if one["type"].nil? problem_url elsif one["type"] && one["type"] != "false" "'#{one["type"]}'" elsif one["type"] && one["type"] == "false" nil end end