class Hanami::Extensions::View::SliceConfiguredHelpers

Provides slice-specific helper methods for any view object requiring access to helpers.

@api public @since 2.1.0

Attributes

slice[R]

Public Class Methods

new(slice) click to toggle source

@api private @since 2.1.0

Calls superclass method
# File lib/hanami/extensions/view/slice_configured_helpers.rb, line 15
def initialize(slice)
  super()
  @slice = slice
end

Public Instance Methods

extended(klass) click to toggle source

@api private @since 2.1.0

# File lib/hanami/extensions/view/slice_configured_helpers.rb, line 22
def extended(klass)
  include_helpers(klass)
end
inspect() click to toggle source

@return [String]

@api public @since 2.1.0

# File lib/hanami/extensions/view/slice_configured_helpers.rb, line 30
def inspect
  "#<#{self.class.name}[#{slice.name}]>"
end

Private Instance Methods

helpers_module(slice) click to toggle source
# File lib/hanami/extensions/view/slice_configured_helpers.rb, line 46
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
include_helpers(klass) click to toggle source
# File lib/hanami/extensions/view/slice_configured_helpers.rb, line 36
def include_helpers(klass)
  if mod = helpers_module(slice.app)
    klass.include(mod)
  end

  if mod = helpers_module(slice)
    klass.include(mod)
  end
end