Class: Sinatra::Schema::Root
- Inherits:
-
Object
- Object
- Sinatra::Schema::Root
- Includes:
- Singleton
- Defined in:
- lib/sinatra/schema/root.rb
Instance Attribute Summary collapse
-
#resources ⇒ Object
Returns the value of attribute resources.
Instance Method Summary collapse
- #add_resource(res) ⇒ Object
- #find_definition(id) ⇒ Object
-
#initialize ⇒ Root
constructor
A new instance of Root.
Constructor Details
#initialize ⇒ Root
Returns a new instance of Root.
8 9 10 |
# File 'lib/sinatra/schema/root.rb', line 8 def initialize @resources = {} end |
Instance Attribute Details
#resources ⇒ Object
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 |