class Sinatra::Schema::Link

Attributes

action_block[RW]
description[RW]
href[RW]
method[RW]
properties[RW]
rel[RW]
resource[RW]
title[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/sinatra/schema/link.rb, line 6
def initialize(options={})
  @resource   = options[:resource]
  @method     = options[:method]
  @href       = options[:href]
  @properties = {}
end

Public Instance Methods

handler() click to toggle source
# 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) click to toggle source
# File lib/sinatra/schema/link.rb, line 13
def register(app)
  app.send(method, href, &handler)
end