class Rambo::RamlModels::Api
Attributes
options[R]
schema[R]
Public Class Methods
new(parsed_raml, options={})
click to toggle source
# File lib/rambo/raml_models/api.rb, line 6 def initialize(parsed_raml, options={}) @schema, @options = parsed_raml, options end
Public Instance Methods
headers()
click to toggle source
# File lib/rambo/raml_models/api.rb, line 22 def headers @headers ||= Rambo::RamlModels::Headers.new({}) add_content_type_header!(@headers) add_security_headers!(@headers) @headers end
resources()
click to toggle source
# File lib/rambo/raml_models/api.rb, line 10 def resources @resources ||= schema.resources.map {|resource| Rambo::RamlModels::Resource.new(resource, headers) } end
security_schemes()
click to toggle source
# File lib/rambo/raml_models/api.rb, line 18 def security_schemes @security_schemes ||= schema.security_schemes.map {|scheme| Rambo::RamlModels::SecurityScheme.new(scheme, options) } end
title()
click to toggle source
# File lib/rambo/raml_models/api.rb, line 14 def title @title ||= schema.title end
Private Instance Methods
add_content_type_header!(h)
click to toggle source
# File lib/rambo/raml_models/api.rb, line 33 def add_content_type_header!(h) h.add({ "Content-Type" => schema.media_type }) if schema.media_type end
add_security_headers!(h)
click to toggle source
# File lib/rambo/raml_models/api.rb, line 37 def add_security_headers!(h) return unless schema.secured_by scheme = security_schemes.find {|sch| sch.title == schema.secured_by.first } h.merge!(scheme.headers) end