Class: Sinatra::Schema::Link
- Inherits:
-
Object
- Object
- Sinatra::Schema::Link
- Defined in:
- lib/sinatra/schema/link.rb
Instance Attribute Summary collapse
-
#action_block ⇒ Object
Returns the value of attribute action_block.
-
#description ⇒ Object
Returns the value of attribute description.
-
#href ⇒ Object
Returns the value of attribute href.
-
#method ⇒ Object
Returns the value of attribute method.
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#rel ⇒ Object
Returns the value of attribute rel.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #handler ⇒ Object
-
#initialize(options = {}) ⇒ Link
constructor
A new instance of Link.
- #register(app) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Link
Returns a new instance of Link.
6 7 8 9 10 11 |
# File 'lib/sinatra/schema/link.rb', line 6 def initialize(={}) @resource = [:resource] @method = [:method] @href = [:href] @properties = {} end |
Instance Attribute Details
#action_block ⇒ Object
Returns the value of attribute action_block.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def action_block @action_block end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def description @description end |
#href ⇒ Object
Returns the value of attribute href.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def href @href end |
#method ⇒ Object
Returns the value of attribute method.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def method @method end |
#properties ⇒ Object
Returns the value of attribute properties.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def properties @properties end |
#rel ⇒ Object
Returns the value of attribute rel.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def rel @rel end |
#resource ⇒ Object
Returns the value of attribute resource.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def resource @resource end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/sinatra/schema/link.rb', line 4 def title @title end |
Instance Method Details
#handler ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sinatra/schema/link.rb', line 17 def handler link = self lambda do begin schema_params = parse_params(link.properties) validate_params!(schema_params, link.properties) res = instance_exec(schema_params, &link.action_block) link.resource.validate_response!(link.rel, res) res end end end |
#register(app) ⇒ Object
13 14 15 |
# File 'lib/sinatra/schema/link.rb', line 13 def register(app) app.send(method, href, &handler) end |