Sha256: 1b2a45610afb76c786badd580aa6210d65205b58ccb80ec380a895e0f532a6e3

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module Hanami
  # @since 0.9.0
  # @api private
  module Components
    # @since 0.9.0
    # @api private
    module App
      # hanami-view configuration for a single Hanami application in the project.
      #
      # @since 0.9.0
      # @api private
      class View
        # Configure hanami-view for a single Hanami application in the project.
        #
        # @param app [Hanami::Configuration::App] a Hanami application
        #
        # @since 0.9.0
        # @api private
        #
        # rubocop:disable Metrics/AbcSize
        # rubocop:disable Metrics/MethodLength
        def self.resolve(app)
          config    = app.configuration
          namespace = app.namespace

          unless namespace.const_defined?('View', false)
            view = Hanami::View.duplicate(namespace) do
              root   config.templates
              layout config.layout

              config.view.__apply(self)
            end

            namespace.const_set('View', view)
          end

          Components.resolved "#{app.app_name}.view", namespace.const_get('View').configuration
        end
      end
      # rubocop:enable Metrics/MethodLength
      # rubocop:enable Metrics/AbcSize
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-1.3.5 lib/hanami/components/app/view.rb
hanami-1.3.4 lib/hanami/components/app/view.rb