Sha256: 73de8fad0867b7621e8bc2afaa973730709ec41fad7af78113b0610f3f66b10b
Contents?: true
Size: 679 Bytes
Versions: 15
Compression:
Stored size: 679 Bytes
Contents
module OasRails module Builders class ParameterBuilder def initialize(specification) @specification = specification @parameter = Spec::Parameter.new(specification) end 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 def extract_word_before(string, param) regex = %r{/(\w+)/\{#{param}\}} match = string.match(regex) match ? match[1] : nil end def build @parameter end end end end
Version data entries
15 entries across 15 versions & 1 rubygems