Files: README CHANGELOG COPYING lib/camping.rb lib/camping/reloader.rb lib/camping/fastcgi.rb lib/camping/session.rb lib/camping/db.rb lib/camping/webrick.rb | classes: MissingLibrary Camping Camping::Views Camping::Session Camping::Controllers Camping::Controllers::ServerError Camping::Controllers::NotFound Camping::Helpers Camping::Base Camping::Models Camping::Models::Session Camping::FastCGI Camping::Mab Camping::Reloader Camping::H WEBrick WEBrick::CampingHandler

Class Camping::H < Object

(in files lib/camping.rb )

An object-like Hash, based on ActiveSupport‘s HashWithIndifferentAccess. All Camping query string and cookie variables are loaded as this.

To access the query string, for instance, use the @input variable.

  module Blog::Models
    class Index < R '/'
      def get
        if page = @input.page.to_i > 0
          page -= 1
        end
        @posts = Post.find :all, :offset => page * 20, :limit => 20
        render :index
      end
    end
  end

In the above example if you visit /?page=2, you‘ll get the second page of twenty posts. You can also use @input[:page] or @input[‘page’] to get the value for the page query variable.

Use the @cookies variable in the same fashion to access cookie variables. Also, the @env variable is an H containing the HTTP headers and server info.

Includes

Methods

Public Instance method: method_missing(m,*a)

Gets or sets keys in the hash.

  @cookies.my_favorite = :macadamian
  @cookies.my_favorite
  => :macadamian
     # File lib/camping.rb, line 129
129:     def method_missing(m,*a)
130:         m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m]:raise(NoMethodError,"#{m}")
131:     end