Module: Goodmail::Configuration

Included in:
Goodmail
Defined in:
lib/goodmail/configuration.rb

Overview

Handles configuration settings for the Goodmail gem.

Constant Summary collapse

DEFAULT_CONFIG =

Default configuration values

OpenStruct.new(
  brand_color:  "#348eda",
  company_name: "Example Inc.",
  logo_url:     nil,
  # Optional: URL the header logo links to.
  company_url:  nil,
  # Optional: Global default unsubscribe URL.
  unsubscribe_url: nil,
  # Optional: Default preheader text (appears after subject in inbox preview).
  default_preheader: nil,
  # Optional footer text (e.g., "Why you received this email")
  footer_text:  nil,
  # Show a visible unsubscribe link in the footer?
  show_footer_unsubscribe_link: false,
  # Text for the footer unsubscribe link
  footer_unsubscribe_link_text: "Unsubscribe"
).freeze
REQUIRED_CONFIG_KEYS =

Define required keys that MUST be set by the user (cannot be nil/empty)

%i[company_name].freeze

Instance Method Summary collapse

Instance Method Details

#configObject

Returns the current configuration object. Initializes with a copy of the defaults if not already configured.



38
39
40
41
# File 'lib/goodmail/configuration.rb', line 38

def config
  @config = DEFAULT_CONFIG.dup unless defined?(@config) && @config
  @config
end

#configure {|config| ... } ⇒ Object

Provides the configuration block helper. Ensures validation runs after the block is executed.

Yields:



31
32
33
34
# File 'lib/goodmail/configuration.rb', line 31

def configure
  yield config # Ensures config is initialized via accessor
  validate_config!(config)
end

#reset_config!Object

Resets the configuration back to the default values. Primarily useful for testing environments.



45
46
47
# File 'lib/goodmail/configuration.rb', line 45

def reset_config!
  @config = nil
end