Class: RamlParser::Model::Method

Inherits:
Object
  • Object
show all
Defined in:
lib/raml_parser/model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, protocols = [], secured_by = []) ⇒ Method

Returns a new instance of Method.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/raml_parser/model.rb', line 58

def initialize(method, description = nil, query_parameters = {}, responses = {}, bodies = {}, headers = {}, is = {}, protocols = [], secured_by = [])
  @method = method
  @description = description
  @query_parameters = query_parameters
  @responses = responses
  @bodies = bodies
  @headers = headers
  @is = is
  @protocols = protocols
  @secured_by = secured_by
end

Instance Attribute Details

#bodiesObject

Returns the value of attribute bodies.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def bodies
  @bodies
end

#descriptionObject

Returns the value of attribute description.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def description
  @description
end

#headersObject

Returns the value of attribute headers.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def headers
  @headers
end

#isObject

Returns the value of attribute is.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def is
  @is
end

#methodObject

Returns the value of attribute method.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def method
  @method
end

#protocolsObject

Returns the value of attribute protocols.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def protocols
  @protocols
end

#query_parametersObject

Returns the value of attribute query_parameters.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def query_parameters
  @query_parameters
end

#responsesObject

Returns the value of attribute responses.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def responses
  @responses
end

#secured_byObject

Returns the value of attribute secured_by.



56
57
58
# File 'lib/raml_parser/model.rb', line 56

def secured_by
  @secured_by
end

Class Method Details

.merge(a, b) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/raml_parser/model.rb', line 70

def self.merge(a, b)
  method = Method.new(b.method)

  method.description = if b.description then b.description else a.description end
  method.query_parameters = a.query_parameters.merge(b.query_parameters)
  method.responses = a.responses.merge(b.responses)
  method.bodies = a.bodies.merge(b.bodies)
  method.headers = a.headers.merge(b.headers)
  method.is = a.is.merge(b.is)
  method.protocols = (a.protocols + b.protocols).uniq
  method.secured_by = (a.secured_by + b.secured_by).uniq

  method
end