Module: Hanami::Mailer::ViewIntegration::ClassMethods Private

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.

Class-level methods added to mailer classes when Hanami::View is available.

Instance Method Summary collapse

Instance Method Details

#decorate(*names, **options, &block) ⇒ 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.

Defines an exposure that will be decorated with a matching view part.

This is a shorthand for ‘expose(…, decorate: true)`.



73
74
75
# File 'lib/hanami/mailer/view_integration.rb', line 73

def decorate(*names, **options, &block)
  expose(*names, **options, decorate: true, &block)
end

#default_viewObject

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.

The auto-built default view for this mailer class.

Built lazily on first access (the first render) and memoized, since it depends only on class-level state (config, exposures, class name) and is identical for every instance. Returns nil when view integration is disabled or no usable template paths are configured.

Note: because the view is memoized on first render, later changes to view-related config or exposures are not reflected. Mailer classes are configured once at definition time, so this is intentional.



62
63
64
65
66
# File 'lib/hanami/mailer/view_integration.rb', line 62

def default_view
  return @default_view if defined?(@default_view)

  @default_view = config.integrate_view ? DefaultViewBuilder.call(self) : nil
end