Module: Lunetas::Candy::RequestWrapper::InstanceMethods

Defined in:
lib/lunetas/candy/request_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#development?true, false

Is lunetas running in development?

Returns:

  • (true, false)


40
41
42
43
44
45
46
# File 'lib/lunetas/candy/request_wrapper.rb', line 40

def development?
  if ENV['RAILS_ENV']
    ENV['RAILS_ENV'] == 'development'
  else
    ENV['RACK_ENV'].nil? || ENV['RACK_ENV'] == 'development'
  end
end

#paramsHash

Gets the request parameters.

Returns:

  • (Hash)


13
14
15
# File 'lib/lunetas/candy/request_wrapper.rb', line 13

def params
  @req.params
end

#redirect(target, status = 302) ⇒ nil

Redirects to some location.

Parameters:

  • target (String)

    the location to redirect to.

  • status (Fixnum) (defaults to: 302)

    the redirect status.

Returns:

  • (nil)


33
34
35
36
# File 'lib/lunetas/candy/request_wrapper.rb', line 33

def redirect(target, status = 302)
  set_header 'Location', target
  @lunetas_redirect = [302, "Moved to #{target}"]
end

#requestRack::Request

Gets the current request object.

Returns:

  • (Rack::Request)


19
20
21
# File 'lib/lunetas/candy/request_wrapper.rb', line 19

def request
  @req
end

#sessionHash

Gets the current session.

Returns:

  • (Hash)


25
26
27
# File 'lib/lunetas/candy/request_wrapper.rb', line 25

def session
  @req.session
end

#set_content_type(content_type) ⇒ nil

Sets the ContentType for this instance. This overrides the class ContentType.

Parameters:

  • content_type (String)

    the ContentType.

Returns:

  • (nil)


52
53
54
# File 'lib/lunetas/candy/request_wrapper.rb', line 52

def set_content_type(content_type)
  set_header 'Content-Type', content_type
end

#set_header(header, value) ⇒ nil

Sets a Header for this instance.

Parameters:

  • header (String, Symbol)

    the Header to be set.

  • value (String)

    the value of the Header.

Returns:

  • (nil)


60
61
62
# File 'lib/lunetas/candy/request_wrapper.rb', line 60

def set_header(header, value)
  @lunetas_headers[header.to_s] = value
end

#xhr?true, false

Called from an XML Http Request?

Returns:

  • (true, false)


7
8
9
# File 'lib/lunetas/candy/request_wrapper.rb', line 7

def xhr?
  @req.xhr?
end