Class: Shamu::Rack::QueryParams

Inherits:
Object
  • Object
show all
Defined in:
lib/shamu/rack/query_params.rb

Overview

Expose the query string and post data parameters as a hash.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ QueryParams

Returns a new instance of QueryParams.

Parameters:

  • env (Hash)

    the Rack environment



13
14
15
# File 'lib/shamu/rack/query_params.rb', line 13

def initialize( env )
  @env = env
end

Class Method Details

.createQueryParams

Returns:



8
9
10
# File 'lib/shamu/rack/query_params.rb', line 8

def self.create( * )
  fail "Add Shamu::Rack::QueryParamsMiddleware to use Shamu::Rack::QueryParams"
end

Instance Method Details

#get(key) ⇒ String Also known as: []

Get a cookie value from the browser.

Parameters:

  • key (String)

    or name of the cookie

Returns:

  • (String)

    cookie value



20
21
22
23
# File 'lib/shamu/rack/query_params.rb', line 20

def get( key )
  key = key.to_s
  env_query_params[ key ]
end

#key?(name) ⇒ Boolean

Returns true if the cookie has been set.

Parameters:

  • name (String)

Returns:

  • (Boolean)

    true if the cookie has been set.



28
29
30
# File 'lib/shamu/rack/query_params.rb', line 28

def key?( name )
  env_query_params.key?( name.to_s )
end