Class: Sinatra::Schema::Root

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/sinatra/schema/root.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRoot

Returns a new instance of Root.



8
9
10
# File 'lib/sinatra/schema/root.rb', line 8

def initialize
  @resources = {}
end

Instance Attribute Details

#resourcesObject

Returns the value of attribute resources.



6
7
8
# File 'lib/sinatra/schema/root.rb', line 6

def resources
  @resources
end

Instance Method Details

#add_resource(res) ⇒ Object



12
13
14
# File 'lib/sinatra/schema/root.rb', line 12

def add_resource(res)
  @resources[res.id] = res
end

#find_definition(id) ⇒ Object



16
17
18
19
20
# File 'lib/sinatra/schema/root.rb', line 16

def find_definition(id)
  resource_id, def_id = id.to_s.split("/", 2)
  return unless resource = resources[resource_id.to_sym]
  resource.defs[def_id.to_sym]
end