Sha256: 67bc48baa565c21197dc0657c8448511d5271a035c777b106afb5e1e0345c4ed

Contents?: true

Size: 1.41 KB

Versions: 15

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

# :reek:UtilityFunction
# :reek:InstanceVariableAssumption
# :reek:TooManyInstanceVariables
# :reek:DuplicateMethodCall
# :reek:TooManyStatements

module SwaggerDocsGenerator
  module Actions
    # # Test :parameters
    #
    # Complete parameters field for action
    class Parameter
      def initialize(&block)
        @param = nil
        instance_eval(&block) if block_given?
      end

      def to_hash
        @param.to_hash
      end

      private

      def name(text)
        @name = text
      end

      def description(text)
        @description = text
      end

      def required(text)
        @required = text
      end

      def body(&block)
        @param = Body.new(&block)
      end

      def form(&block)
        @param = Form.new(&block)
      end

      def header(&block)
        @param = Header.new(&block)
      end

      def path(&block)
        @param = Path.new(&block)
      end

      def query(&block)
        @param = Query.new(&block)
      end

      def test_value(value, default)
        value.empty? ? default : value
      end
    end
  end
end

require 'swagger_docs_generator/parser/actions/parameters/body'
require 'swagger_docs_generator/parser/actions/parameters/form'
require 'swagger_docs_generator/parser/actions/parameters/header'
require 'swagger_docs_generator/parser/actions/parameters/path'
require 'swagger_docs_generator/parser/actions/parameters/query'

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
swagger_docs_generator-0.5.1 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.5.0.pre.42 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.4.0 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.6 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.6.pre.34 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.5 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.5.pre.31 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.4.pre.26 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.4 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.4.pre.23 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.3 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.2 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.1 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.0.pre.19 lib/swagger_docs_generator/parser/actions/parameters.rb
swagger_docs_generator-0.3.0.pre.18 lib/swagger_docs_generator/parser/actions/parameters.rb