Sha256: 11af868497db3a314082cd895bb629d8f0663e2be37dda05a63b2182e740ece5
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Hanami class View class ApplicationContext < Module attr_reader :provider attr_reader :application def initialize(provider) @provider = provider @application = provider.respond_to?(:application) ? provider.application : Hanami.application end def included(context_class) define_initialize context_class.include(InstanceMethods) end private def define_initialize inflector = application.inflector routes = application[:routes_helper] if application.key?(:routes_helper) define_method :initialize do |**options| @inflector = options[:inflector] || inflector @routes = options[:routes] || routes super(**options) end end module InstanceMethods attr_reader :inflector attr_reader :routes 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hanami-view-2.0.0.alpha6 | lib/hanami/view/application_context.rb |
hanami-view-2.0.0.alpha5 | lib/hanami/view/application_context.rb |