Overrides in Camping

If you want to add a call to all the controllers in your Camping miroframework app you can use before or after overrides. These are similar to the before_filter in Rails.

Remember to return the superclass or Camping will throw a “Read error: #<NoMethodError: undefined method `status’ for nil:NilClass>” because it can’t call back into the returned controller. A modification of the above linked wiki page example illustrates -


Camping.goes :YourApp

module YourSession
  def service(*a)
    @session = YourApp::Session.new
    s = super(*a)
    @session.close
    #return s from above after completing
    s
  end
end

module YourApp
  include YourSession
end
Digg this     Create a del.icio.us Bookmark     Add to Newsvine

No Responses to “Overrides in Camping”

No comments yet

Leave a Reply