Class: RubyApp::Request

Inherits:
Rack::Request
  • Object
show all
Extended by:
Mixins::DelegateMixin
Defined in:
lib/ruby_app/request.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::DelegateMixin

exists?, method_missing

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



12
13
14
# File 'lib/ruby_app/request.rb', line 12

def environment
  @environment
end

Class Method Details

.create!(environment = RubyApp::Application.environment) ⇒ Object



35
36
37
# File 'lib/ruby_app/request.rb', line 35

def self.create!(environment = RubyApp::Application.environment)
  return Thread.current[:_request] = RubyApp::Request.new(environment)
end

.create_context!Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ruby_app/request.rb', line 43

def self.create_context!
  unless RubyApp::Request.exists?
    RubyApp::Request.create!
    RubyApp::Response.create!
    RubyApp::Language.load!
    RubyApp::Session.load!
    begin
      yield
    ensure
      RubyApp::Session.unload!
      RubyApp::Language.unload!
      RubyApp::Response.destroy!
      RubyApp::Request.destroy!
    end
  end
end

.destroy!Object



39
40
41
# File 'lib/ruby_app/request.rb', line 39

def self.destroy!
  return Thread.current[:_request] = nil
end

.exists?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/ruby_app/request.rb', line 31

def self.exists?
  return Thread.current[:_request]
end

.getObject



27
28
29
# File 'lib/ruby_app/request.rb', line 27

def self.get
  return Thread.current[:_request]
end

Instance Method Details

#languageObject



14
15
16
17
# File 'lib/ruby_app/request.rb', line 14

def language
  self.path.gsub(/^#{RubyApp::Application.root_or_nil}/,'') =~ /^\/([^\/\?]+)/
  return $1
end

#parametersObject



23
24
25
# File 'lib/ruby_app/request.rb', line 23

def parameters
  return self.params
end

#queryObject



19
20
21
# File 'lib/ruby_app/request.rb', line 19

def query
  return ::Rack::Utils.parse_query(self.query_string)
end