Sha256: f32a177e2992e895aa2c0f6782222fa7ba4a96822a8a6a91507521087c308ec1

Contents?: true

Size: 752 Bytes

Versions: 9

Compression:

Stored size: 752 Bytes

Contents

module Rambo
  module RamlModels
    class Method
      attr_reader :schema

      def initialize(raml_method, headers=Headers.new({}))
        @schema  = raml_method
        @headers = headers
      end

      def method
        schema.method
      end

      def request_body
        Rambo::RamlModels::Body.new(schema.bodies.first) if has_request_body?
      end

      def description
        @description ||= schema.description
      end

      def headers
        @headers.add(schema.headers) if schema.headers
      end

      def responses
        @responses ||= schema.responses.map {|resp| Rambo::RamlModels::Response.new(resp) }
      end

      private

      def has_request_body?
        !!schema.bodies.first
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rambo_ruby-0.7.1 lib/rambo/raml_models/method.rb
rambo_ruby-0.7.0 lib/rambo/raml_models/method.rb
rambo_ruby-0.6.0 lib/rambo/raml_models/method.rb
rambo_ruby-0.5.0 lib/rambo/raml_models/method.rb
rambo_ruby-0.4.0 lib/rambo/raml_models/method.rb
rambo_ruby-0.3.3 lib/rambo/raml_models/method.rb
rambo_ruby-0.3.2 lib/rambo/raml_models/method.rb
rambo_ruby-0.3.1 lib/rambo/raml_models/method.rb
rambo_ruby-0.3.0 lib/rambo/raml_models/method.rb