Class: Sinatra::Schema::DSL::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/schema/dsl/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#appObject

Returns the value of attribute app.



5
6
7
# File 'lib/sinatra/schema/dsl/resources.rb', line 5

def app
  @app
end

#resourceObject

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


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

#propertyObject



16
17
18
# File 'lib/sinatra/schema/dsl/resources.rb', line 16

def property
  DSL::Definitions.new(resource, [resource.defs, resource.properties])
end