class Raml::Parser::Method
Constants
- BASIC_ATTRIBUTES
Attributes
attributes[RW]
method[RW]
parent[RW]
Public Class Methods
new(parent)
click to toggle source
# File lib/raml/parser/method.rb, line 21 def initialize(parent) @parent = parent end
Public Instance Methods
parse(the_method, attributes)
click to toggle source
# File lib/raml/parser/method.rb, line 25 def parse(the_method, attributes) @method = Raml::Method.new(the_method) @attributes = prepare_attributes(attributes) apply_parents_traits apply_traits parse_attributes method end
Private Instance Methods
apply_parents_traits()
click to toggle source
# File lib/raml/parser/method.rb, line 73 def apply_parents_traits parent.trait_names.each do |name| apply_trait(name) end if parent.trait_names.respond_to?(:each) end
apply_trait(name)
click to toggle source
# File lib/raml/parser/method.rb, line 87 def apply_trait(name) unless traits[name].nil? trait_attributes = prepare_attributes(traits[name]) @attributes = trait_attributes.deep_merge(attributes) end end
apply_traits()
click to toggle source
# File lib/raml/parser/method.rb, line 79 def apply_traits attributes['is'].each do |name| apply_trait(name) end if attributes['is'].respond_to?(:each) attributes.delete('is') end
parse_attributes()
click to toggle source
# File lib/raml/parser/method.rb, line 38 def parse_attributes attributes.each do |key, value| case key when *BASIC_ATTRIBUTES method.send("#{key}=".to_sym, value) when 'responses' parse_responses(value) when 'query_parameters' parse_query_parameters(value) when 'body' parse_bodies(value) else raise UnknownAttributeError.new "Unknown method key: #{key}" end end if attributes end
parse_bodies(bodies)
click to toggle source
# File lib/raml/parser/method.rb, line 67 def parse_bodies(bodies) bodies.each do |type, body_attributes| method.bodies << Raml::Parser::Body.new.parse(type, body_attributes) end end
parse_query_parameters(query_parameters)
click to toggle source
# File lib/raml/parser/method.rb, line 61 def parse_query_parameters(query_parameters) query_parameters.each do |name, parameter_attributes| method.query_parameters << Raml::Parser::QueryParameter.new.parse(name, parameter_attributes) end end
parse_responses(responses)
click to toggle source
# File lib/raml/parser/method.rb, line 55 def parse_responses(responses) responses.each do |code, response_attributes| method.responses << Raml::Parser::Response.new.parse(code, response_attributes) end end