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_or_id) ⇒ Resources

Returns a new instance of Resources.



7
8
9
10
11
12
13
14
# File 'lib/sinatra/schema/dsl/resources.rb', line 7

def initialize(app, path_or_id)
  @app = app
  if path_or_id.is_a?(Symbol)
    @resource = Resource.new(id: path_or_id)
  else
    @resource = Resource.new(path: path_or_id)
  end
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

#delete(href = "/", &blk) ⇒ Object



32
33
34
# File 'lib/sinatra/schema/dsl/resources.rb', line 32

def delete(href="/", &blk)
  build_link(:delete, href, &blk)
end

#description(description) ⇒ Object



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

def description(description)
  @resource.description = description
end

#get(href = "/", &blk) ⇒ Object



36
37
38
# File 'lib/sinatra/schema/dsl/resources.rb', line 36

def get(href="/", &blk)
  build_link(:get, href, &blk)
end

#id(id) ⇒ Object



20
21
22
# File 'lib/sinatra/schema/dsl/resources.rb', line 20

def id(id)
  @resource.id = id.to_sym
end

#patch(href = "/", &blk) ⇒ Object



40
41
42
# File 'lib/sinatra/schema/dsl/resources.rb', line 40

def patch(href="/", &blk)
  build_link(:patch, href, &blk)
end

#post(href = "/", &blk) ⇒ Object



44
45
46
# File 'lib/sinatra/schema/dsl/resources.rb', line 44

def post(href="/", &blk)
  build_link(:post, href, &blk)
end

#propertyObject



28
29
30
# File 'lib/sinatra/schema/dsl/resources.rb', line 28

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

#put(href = "/", &blk) ⇒ Object



48
49
50
# File 'lib/sinatra/schema/dsl/resources.rb', line 48

def put(href="/", &blk)
  build_link(:put, href, &blk)
end

#title(title) ⇒ Object



24
25
26
# File 'lib/sinatra/schema/dsl/resources.rb', line 24

def title(title)
  @resource.title = title
end