class Raml::Parser::Root
Constants
- BASIC_ATTRIBUTES
Attributes
attributes[RW]
resource_types[RW]
root[RW]
traits[RW]
Public Class Methods
new()
click to toggle source
# File lib/raml/parser/root.rb, line 16 def initialize @traits = {} @resource_types = {} end
Public Instance Methods
parse(attributes)
click to toggle source
# File lib/raml/parser/root.rb, line 21 def parse(attributes) @root = Raml::Root.new @attributes = prepare_attributes(attributes) parse_attributes root end
Private Instance Methods
parse_attributes()
click to toggle source
# File lib/raml/parser/root.rb, line 30 def parse_attributes attributes.each do |key, value| key = underscore(key) case key when *BASIC_ATTRIBUTES root.send("#{key}=".to_sym, value) when 'traits' parse_traits(value) when 'resource_types' parse_resource_types(value) when 'documentation' parse_documentation(value) when /^\// root.resources << Raml::Parser::Resource.new(self).parse(root, key, value) else raise UnknownAttributeError.new "Unknown root key: #{key}" end end if attributes end
parse_documentation(documentations)
click to toggle source
# File lib/raml/parser/root.rb, line 50 def parse_documentation(documentations) documentations.each do |documentation_attributes| root.documentation << Raml::Parser::Documentation.new.parse(documentation_attributes) end end
parse_resource_types(resource_types)
click to toggle source
# File lib/raml/parser/root.rb, line 56 def parse_resource_types(resource_types) resource_types.each do |type| type.each do |name, type_attributes| @resource_types[name] = type_attributes end end end
parse_traits(traits)
click to toggle source
# File lib/raml/parser/root.rb, line 64 def parse_traits(traits) traits.each do |trait| trait.each do |name, trait_attributes| @traits[name] = trait_attributes end end end