Sha256: fb8134222bafc835af4cdd4f91c3e491464d7dfc75dad9d11087820bf63b1369

Contents?: true

Size: 601 Bytes

Versions: 2

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module Hanami
  class View
    module ApplicationContext
      def initialize(inflector: Hanami.application.inflector, **options)
        @inflector = inflector
        super
      end

      def inflector
        @inflector
      end

      def request
        _options.fetch(:request)
      end

      def session
        request.session
      end

      def flash
        response.flash
      end

      private

      # TODO: create `Request#flash` so we no longer need the `response`
      def response
        _options.fetch(:response)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-view-2.0.0.alpha3 lib/hanami/view/application_context.rb
hanami-view-2.0.0.alpha2 lib/hanami/view/application_context.rb