Module: Sinatra::Hat::Actions
- Included in:
- Maker
- Defined in:
- lib/sinatras-hat/actions.rb
Instance Method Summary collapse
- #create! ⇒ Object
- #destroy! ⇒ Object
- #edit! ⇒ Object
- #generate_actions! ⇒ Object
- #index! ⇒ Object
- #new! ⇒ Object
- #show! ⇒ Object
- #update! ⇒ Object
Instance Method Details
#create! ⇒ Object
35 36 37 38 39 |
# File 'lib/sinatras-hat/actions.rb', line 35 def create! map :create, '/', :verb => :post do |params| create[proxy(params), parse_for_attributes(params)] end end |
#destroy! ⇒ Object
47 48 49 50 51 |
# File 'lib/sinatras-hat/actions.rb', line 47 def destroy! map :destroy, '/:id', :verb => :delete do |params| destroy[call(:record, params), parse_for_attributes(params)] end end |
#edit! ⇒ Object
23 24 25 26 27 |
# File 'lib/sinatras-hat/actions.rb', line 23 def edit! map :edit, '/:id/edit' do |params| call(:record, params) end end |
#generate_actions! ⇒ Object
4 5 6 7 8 9 |
# File 'lib/sinatras-hat/actions.rb', line 4 def generate_actions! only.each { |action| send("#{action}!") } children.each do |resource| mount(resource) end end |
#index! ⇒ Object
11 12 13 14 15 |
# File 'lib/sinatras-hat/actions.rb', line 11 def index! map :index, '/' do |params| call(:finder, params) end end |
#new! ⇒ Object
17 18 19 20 21 |
# File 'lib/sinatras-hat/actions.rb', line 17 def new! map :new, '/new' do |params| proxy(params).new end end |
#show! ⇒ Object
29 30 31 32 33 |
# File 'lib/sinatras-hat/actions.rb', line 29 def show! map :show, '/:id' do |params| call(:record, params) end end |
#update! ⇒ Object
41 42 43 44 45 |
# File 'lib/sinatras-hat/actions.rb', line 41 def update! map :update, '/:id', :verb => :put do |params| update[call(:record, params), parse_for_attributes(params)] end end |