Class: RailsOpenapiGen::Parsers::TemplateProcessors::JbuilderTemplateProcessor
- Inherits:
-
Object
- Object
- RailsOpenapiGen::Parsers::TemplateProcessors::JbuilderTemplateProcessor
- Includes:
- ResponseTemplateProcessor
- Defined in:
- lib/rails-openapi-gen/parsers/template_processors/jbuilder_template_processor.rb
Defined Under Namespace
Classes: JbuilderPathProcessor
Instance Method Summary collapse
- #extract_template_path(action_node, route) ⇒ Object
- #find_default_template(route) ⇒ Object
-
#initialize(controller, action) ⇒ JbuilderTemplateProcessor
constructor
A new instance of JbuilderTemplateProcessor.
Constructor Details
#initialize(controller, action) ⇒ JbuilderTemplateProcessor
Returns a new instance of JbuilderTemplateProcessor.
10 11 12 13 |
# File 'lib/rails-openapi-gen/parsers/template_processors/jbuilder_template_processor.rb', line 10 def initialize(controller, action) @controller = controller @action = action end |
Instance Method Details
#extract_template_path(action_node, route) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rails-openapi-gen/parsers/template_processors/jbuilder_template_processor.rb', line 15 def extract_template_path(action_node, route) return nil unless action_node processor = JbuilderPathProcessor.new(route[:controller], route[:action]) processor.process(action_node) processor.jbuilder_path end |
#find_default_template(route) ⇒ Object
23 24 25 26 |
# File 'lib/rails-openapi-gen/parsers/template_processors/jbuilder_template_processor.rb', line 23 def find_default_template(route) template_path = Rails.root.join("app", "views", route[:controller], "#{route[:action]}.json.jbuilder") File.exist?(template_path) ? template_path.to_s : nil end |