Module: Hanami::Mailer::ViewIntegration Private
- Included in:
- Hanami::Mailer
- Defined in:
- lib/hanami/mailer/view_integration.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Integration module for Hanami::View support.
This module is included when Hanami::View is available, providing automatic view building and settings inheritance.
Defined Under Namespace
Modules: ClassMethods, PrependedMethods Classes: DefaultViewBuilder
Class Method Summary collapse
- .included(base) ⇒ Object private
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hanami/mailer/view_integration.rb', line 12 def self.included(base) base.class_eval do # Prepend the initializer module to wrap initialization prepend PrependedMethods # Add class-level methods, including the lazily-built, memoized default view extend ClassMethods # Whether to automatically build views from exposures # Set to false to disable automatic view integration behavior setting :integrate_view, default: true # The base class used when building the mailer's view. Defaults to Hanami::View, but # may be set to an already-configured view class (such as a view class within a Hanami # app), in which case the built view inherits that class's configuration — context, # parts, scopes, paths, helpers and so on. setting :view_class, default: Hanami::View # Copy all settings from Hanami::View to support default view integration. # This allows mailers to configure view-related settings (like layouts_dir, # default_format, inflector, etc.) without having to manually redefine them. existing_settings = config._settings.keys.to_set Hanami::View.config._settings.each do |setting_def| next if existing_settings.include?(setting_def.name) setting( setting_def.name, default: setting_def.default, constructor: setting_def.constructor, **setting_def. ) end end end |