Sha256: 5e74691fa6f2eb4c7dcbf5208c80890e4944ae04524400c05bf28541394abcfa

Contents?: true

Size: 1.27 KB

Versions: 94

Compression:

Stored size: 1.27 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'rack'

module RubyApp
  require 'ruby_app/mixins'

  class Request < ::Rack::Request
    extend RubyApp::Mixins::DelegateMixin

    attr_reader :environment

    def language
      self.fullpath =~ /^\/([^\/\?]+)/
      return $1
    end

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

    def parameters
      self.params
    end

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

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

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

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

    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

    private

      def initialize(environment)
        super(environment)
        @environment = environment
      end

  end

end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
RubyApp-0.6.60 lib/ruby_app/request.rb
RubyApp-0.6.59 lib/ruby_app/request.rb
RubyApp-0.6.58 lib/ruby_app/request.rb
RubyApp-0.6.57 lib/ruby_app/request.rb
RubyApp-0.6.53 lib/ruby_app/request.rb
RubyApp-0.6.52 lib/ruby_app/request.rb
RubyApp-0.6.51 lib/ruby_app/request.rb
RubyApp-0.6.50 lib/ruby_app/request.rb
RubyApp-0.6.49 lib/ruby_app/request.rb
RubyApp-0.6.48 lib/ruby_app/request.rb
RubyApp-0.6.47 lib/ruby_app/request.rb
RubyApp-0.6.46 lib/ruby_app/request.rb
RubyApp-0.6.45 lib/ruby_app/request.rb
RubyApp-0.6.44 lib/ruby_app/request.rb
RubyApp-0.6.43 lib/ruby_app/request.rb
RubyApp-0.6.42 lib/ruby_app/request.rb
RubyApp-0.6.41 lib/ruby_app/request.rb
RubyApp-0.6.40 lib/ruby_app/request.rb
RubyApp-0.6.39 lib/ruby_app/request.rb
RubyApp-0.6.38 lib/ruby_app/request.rb