Module: Restaurant::Actions
- Defined in:
- lib/restaurant/actions.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/restaurant/actions.rb', line 3 def self.included(base) base.before_filter :require_valid_id, :require_resource, :only => [:show, :update, :destroy] base.before_filter :add_created_at, :only => :create base.before_filter :add_updated_at, :only => :update base.after_filter :expire_resource_cache, :only => [:update, :destroy] base.after_filter :update_resources_version_cache, :only => [:create, :update, :destroy] end |
Instance Method Details
#create ⇒ Object
19 20 21 22 |
# File 'lib/restaurant/actions.rb', line 19 def create collection.insert(resource_params.merge(:_id => resource_id)) respond_with collection.find(:_id => resource_id).first, :location => { :action => :show, :id => resource_id } end |
#destroy ⇒ Object
28 29 30 |
# File 'lib/restaurant/actions.rb', line 28 def destroy respond_with collection.find(:_id => resource_id).remove_all end |
#index ⇒ Object
11 12 13 |
# File 'lib/restaurant/actions.rb', line 11 def index respond_with resources end |
#show ⇒ Object
15 16 17 |
# File 'lib/restaurant/actions.rb', line 15 def show respond_with resource end |
#update ⇒ Object
24 25 26 |
# File 'lib/restaurant/actions.rb', line 24 def update respond_with collection.find(:_id => resource_id).update(:$set => resource_params) end |