Sha256: 645f93cd217dcca5bf94dc3a960f6a6d763538f1a554077c40a95b9ad5976255
Contents?: true
Size: 1.21 KB
Versions: 5
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Hanami module Extensions module View # Provides slice-specific helper methods for any view object requiring access to helpers. # # @api public # @since 2.1.0 class SliceConfiguredHelpers < Module attr_reader :slice # @api private # @since 2.1.0 def initialize(slice) super() @slice = slice end # @api private # @since 2.1.0 def extended(klass) include_helpers(klass) end # @return [String] # # @api public # @since 2.1.0 def inspect "#<#{self.class.name}[#{slice.name}]>" end private def include_helpers(klass) if mod = helpers_module(slice.app) klass.include(mod) end if mod = helpers_module(slice) klass.include(mod) end end def helpers_module(slice) return unless slice.namespace.const_defined?(:Views) return unless slice.namespace.const_get(:Views).const_defined?(:Helpers) slice.namespace.const_get(:Views).const_get(:Helpers) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems