Sha256: 33ad5e61f2580bdded39b0b6295c1833c584feb8054382dfb5cfda74cbc7a0fb

Contents?: true

Size: 943 Bytes

Versions: 4

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

module Hanami
  module Extensions
    module View
      # @api private
      class SliceConfiguredHelpers < Module
        attr_reader :slice

        def initialize(slice)
          super()
          @slice = slice
        end

        def extended(klass)
          include_helpers(klass)
        end

        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

4 entries across 4 versions & 1 rubygems

Version Path
hanami-2.1.0.rc1 lib/hanami/extensions/view/slice_configured_helpers.rb
hanami-2.1.0.beta2.1 lib/hanami/extensions/view/slice_configured_helpers.rb
hanami-2.1.0.beta2 lib/hanami/extensions/view/slice_configured_helpers.rb
hanami-2.1.0.beta1 lib/hanami/extensions/view/slice_configured_helpers.rb