Sha256: 467b2bf8fb1e9fe9eac1dd89f7cfce2fd3ba81e246b043b59961a15e89651a81

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

module Pakyow
  # Helpers available anywhere
  #
  # @api public
  module Helpers
    def context
      @context or raise NoContextError
    end

    def logger
      request.logger || Pakyow.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

    # Returns the primary app environment.
    #
    # @api public
    def env
      config.env
    end

    # Helpers for Pakyow::App
    #
    # @api public
    module App; end

    # Helpers for Pakyow::CallContext
    #
    # @api public
    module Context; end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pakyow-core-0.11.3 pakyow-core/lib/pakyow/core/helpers.rb
pakyow-core-0.11.2 pakyow-core/lib/pakyow/core/helpers.rb
pakyow-core-0.11.1 pakyow-core/lib/pakyow/core/helpers.rb
pakyow-core-0.11.0 pakyow-core/lib/pakyow/core/helpers.rb