Class: Sinatra::Schema::DSL::Resources
- Inherits:
-
Object
- Object
- Sinatra::Schema::DSL::Resources
- Defined in:
- lib/sinatra/schema/dsl/resources.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #description(description) ⇒ Object
-
#initialize(app, path) ⇒ Resources
constructor
A new instance of Resources.
- #link(method, href = "/", &blk) ⇒ Object
- #property ⇒ Object
Constructor Details
#initialize(app, path) ⇒ Resources
Returns a new instance of Resources.
7 8 9 10 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 7 def initialize(app, path) @app = app @resource = Resource.new(path: path) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5 6 7 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 5 def app @app end |
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 5 def resource @resource end |
Instance Method Details
#description(description) ⇒ Object
12 13 14 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 12 def description(description) @resource.description = description end |
#link(method, href = "/", &blk) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 20 def link(method, href="/", &blk) dsl = DSL::Links.new(resource: resource, method: method, href: href) blk.call(dsl) link = dsl.link link.register(app) resource.links << link end |
#property ⇒ Object
16 17 18 |
# File 'lib/sinatra/schema/dsl/resources.rb', line 16 def property DSL::Definitions.new(resource, [resource.defs, resource.properties]) end |