Class: Sinatra::EventContext

Inherits:
Object
  • Object
show all
Includes:
Builder, Erb, Haml, RenderingHelpers, ResponseHelpers, Streaming
Defined in:
lib/codebutler/sinatra.rb

Constant Summary

Constants included from Streaming

Streaming::DEFAULT_SEND_FILE_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Builder

#builder

Methods included from Haml

#haml

Methods included from Erb

#erb

Methods included from RenderingHelpers

#determine_layout, #render

Methods included from ResponseHelpers

#headers, #redirect

Constructor Details

#initialize(request, response, route_params) ⇒ EventContext

Returns a new instance of EventContext.



584
585
586
587
588
589
# File 'lib/codebutler/sinatra.rb', line 584

def initialize(request, response, route_params)
  @request = request
  @response = response
  @route_params = route_params
  @response.body = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &b) ⇒ Object (private)



605
606
607
# File 'lib/codebutler/sinatra.rb', line 605

def method_missing(name, *args, &b)
  @response.send(name, *args, &b)
end

Instance Attribute Details

#requestObject

Returns the value of attribute request.



580
581
582
# File 'lib/codebutler/sinatra.rb', line 580

def request
  @request
end

#responseObject

Returns the value of attribute response.



580
581
582
# File 'lib/codebutler/sinatra.rb', line 580

def response
  @response
end

Instance Method Details

#complete(returned) ⇒ Object



599
600
601
# File 'lib/codebutler/sinatra.rb', line 599

def complete(returned)
  @response.body || returned
end

#paramsObject



591
592
593
# File 'lib/codebutler/sinatra.rb', line 591

def params
  @params = @route_params.merge(@request.params)
end

#stop(*args) ⇒ Object



595
596
597
# File 'lib/codebutler/sinatra.rb', line 595

def stop(*args)
  throw :halt, args
end