Class: OasRails::Builders::ParameterBuilder
- Inherits:
-
Object
- Object
- OasRails::Builders::ParameterBuilder
- Defined in:
- lib/oas_rails/builders/parameter_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
- #extract_word_before(string, param) ⇒ Object
- #from_path(path, param) ⇒ Object
-
#initialize(specification) ⇒ ParameterBuilder
constructor
A new instance of ParameterBuilder.
Constructor Details
#initialize(specification) ⇒ ParameterBuilder
Returns a new instance of ParameterBuilder.
4 5 6 7 |
# File 'lib/oas_rails/builders/parameter_builder.rb', line 4 def initialize(specification) @specification = specification @parameter = Spec::Parameter.new(specification) end |
Instance Method Details
#build ⇒ Object
23 24 25 |
# File 'lib/oas_rails/builders/parameter_builder.rb', line 23 def build @parameter end |
#extract_word_before(string, param) ⇒ Object
17 18 19 20 21 |
# File 'lib/oas_rails/builders/parameter_builder.rb', line 17 def extract_word_before(string, param) regex = %r{/(\w+)/\{#{param}\}} match = string.match(regex) match ? match[1] : nil end |
#from_path(path, param) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/oas_rails/builders/parameter_builder.rb', line 9 def from_path(path, param) @parameter.name = param @parameter.in = 'path' @parameter.description = "#{param.split('_')[-1].titleize} of existing #{extract_word_before(path, param).singularize}." self end |