Class: Jellyfish::Sinatra

Inherits:
Controller show all
Defined in:
lib/jellyfish/sinatra.rb

Constant Summary

Constants included from Jellyfish

LOCATION, PATH_INFO, RACK_ERRORS, REQUEST_METHOD, VERSION

Instance Attribute Summary collapse

Attributes inherited from Controller

#env, #routes

Instance Method Summary collapse

Methods inherited from Controller

#body, #call, #forward, #found, #headers_merge, #initialize, #path_info, #request_method

Methods included from Jellyfish

#call, #controller, #initialize, #protect

Constructor Details

This class inherits a constructor from Jellyfish::Controller

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/jellyfish/sinatra.rb', line 7

def params
  @params
end

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/jellyfish/sinatra.rb', line 7

def request
  @request
end

Instance Method Details

#block_call(argument, block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jellyfish/sinatra.rb', line 8

def block_call argument, block
  @request = Rack::Request.new(env)
  @params  = indifferent_params(if argument.kind_of?(MatchData)
  then # merge captured data from matcher into params as sinatra
    request.params.merge(Hash[argument.names.zip(argument.captures)])
  else
    request.params
  end)

  super
end