Sha256: a3c93afc9092fe70dcc789d91e5db06b7da446766b0b17b393628a374d9c2ba7

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 Bytes

Contents

require "peictt/version"
require "peictt/dependencies"

module Peictt
  class Application
    ASSETS_REGEXP = %r(^[(\/|)]assets\/[(css|js)]+\/([a-z_]+\.[(css|js)]+)$)
    def call(env)
      if ASSETS_REGEXP =~ env["PATH_INFO"]
        return Peictt::Controller.get_asset($1)
      end
      @@request = Rack::Request.new(env)
      get_rack_app(env)
    end

    def self.config
    end

    def self.params
      @@request.params
    end

    def self.session
      @@request.session
    end

    def self.routes
      @route_builder ||= Peictt::Builder::Router.new
    end

    def get_rack_app(env)
      route, params = Peictt::Http::Checker.check_url(env,
                                                      self.class.routes.all)
      @@request.params.merge! params unless params.nil?
      if route.respond_to? :controller
        return route.controller.action(route.action).call(env)
      else
        return route.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peictt-0.1.1 lib/peictt.rb