Class: RubyApp::Request

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::DelegateMixin

method_missing

Class Method Details

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ruby_app/request.rb', line 33

def self.create!(environment = RubyApp::Application.environment)
  Thread.current[:_request] = RubyApp::Request.new(environment)
  Thread.current[:_rendered] = {}

  if block_given?
    begin
      RubyApp::Language.load! do
        RubyApp::Session.create! do
          return yield
        end
      end
    ensure
      self.destroy!
    end
  else
    begin
      RubyApp::Language.load!
      begin
        RubyApp::Session.create!
      rescue
        RubyApp::Language.unload!
        raise
      end
    rescue
      self.destroy!
      raise
    end
  end

end

.destroy!Object



64
65
66
67
# File 'lib/ruby_app/request.rb', line 64

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

.getObject



29
30
31
# File 'lib/ruby_app/request.rb', line 29

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

Instance Method Details

#languageObject



16
17
18
19
# File 'lib/ruby_app/request.rb', line 16

def language
  self.fullpath =~ /^\/([^\/\?]+)/
  $1 || RubyApp::Application.options.default_language
end

#parametersObject



25
26
27
# File 'lib/ruby_app/request.rb', line 25

def parameters
  self.params
end

#queryObject



21
22
23
# File 'lib/ruby_app/request.rb', line 21

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