Sha256: 6378dcd1232bcdafc37ab3fa1448775576fe9850b089a6f10616bf135e9dd28a

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

module Pakyow
  # For methods that should be accessible anywhere
  module Helpers
    def context
      @context or raise NoContextError
    end

    def logger
      request.logger
    end

    def router
      RouteLookup.new
    end

    def request
      context ? context.request : nil
    end
    alias_method :req, :request

    def response
      context ? context.response : nil
    end
    alias_method :res, :response

    def params
      request ? request.params : {}
    end

    def session
      request ? request.session : {}
    end

    def cookies
      request ? request.cookies : {}
    end

    def config
      Pakyow::Config
    end
  end

  # For methods that should only be accessible through App
  module AppHelpers; end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-core-0.10.2 pakyow-core/lib/core/helpers.rb
pakyow-core-0.10.1 pakyow-core/lib/core/helpers.rb
pakyow-core-0.10.0 pakyow-core/lib/core/helpers.rb