Module: Sinatra::Resource

Defined in:
lib/sinatra/resource.rb

Instance Method Summary collapse

Instance Method Details

#_delete(&block) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/sinatra/resource.rb', line 51

def _delete(&block)
  if block.arity == 0
    get "/delete", &block
  else
    get("/delete") { block.call(params[:id]) }
  end
end

#_new(&block) ⇒ Object



19
20
21
# File 'lib/sinatra/resource.rb', line 19

def _new(&block)
  get "/new", &block
end

#create(&block) ⇒ Object



23
24
25
# File 'lib/sinatra/resource.rb', line 23

def create(&block)
  post &block
end

#destroy(&block) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/sinatra/resource.rb', line 59

def destroy(&block)
  if block.arity == 0
    delete &block
  else
    delete { block.call(params[:id]) }
  end
end

#edit(&block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/sinatra/resource.rb', line 35

def edit(&block)
  if block.arity == 0
    get "/edit", &block
  else
    get("/edit") { block.call(params[:id]) }
  end
end

#index(&block) ⇒ Object



15
16
17
# File 'lib/sinatra/resource.rb', line 15

def index(&block)
  get &block
end

#member(&block) ⇒ Object



11
12
13
# File 'lib/sinatra/resource.rb', line 11

def member(&block)
  scope ":id", &block
end

#resource(name, &block) ⇒ Object Also known as: resources



6
7
8
# File 'lib/sinatra/resource.rb', line 6

def resource(name, &block)
  scope name, &block
end

#show(&block) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/sinatra/resource.rb', line 27

def show(&block)
  if block.arity == 0
    get &block
  else
    get { block.call(params[:id]) }
  end
end

#update(&block) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/sinatra/resource.rb', line 43

def update(&block)
  if block.arity == 0
    put &block
  else
    put { block.call(params[:id]) }
  end
end