Class: Apipie::Generator::Swagger::PathDecorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Apipie::Generator::Swagger::PathDecorator
- Defined in:
- lib/apipie/generator/swagger/path_decorator.rb
Instance Method Summary collapse
- #param?(param_name) ⇒ Boolean
- #param_names ⇒ Object
- #swagger_path(controller_method = nil) ⇒ Apipie::Generator::Swagger::PathDecorator
Instance Method Details
#param?(param_name) ⇒ Boolean
7 8 9 |
# File 'lib/apipie/generator/swagger/path_decorator.rb', line 7 def param?(param_name) param_names.include?(param_name) end |
#param_names ⇒ Object
2 3 4 |
# File 'lib/apipie/generator/swagger/path_decorator.rb', line 2 def param_names @param_names ||= scan(/:(\w+)/).map { |ar| ar[0].to_sym } end |
#swagger_path(controller_method = nil) ⇒ Apipie::Generator::Swagger::PathDecorator
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/apipie/generator/swagger/path_decorator.rb', line 14 def swagger_path(controller_method = nil) current_path = gsub(/:(\w+)/, '{\1}').gsub(%r{/$}, '') unless current_path.starts_with?('/') warn_for_missing_slash(controller_method) if controller_method.present? current_path = "/#{current_path}" end current_path end |