ruby write a configuration module or class

  module Mailer
    class << self
      attr_accessor :configuration
      
      def configure
        self.configuration ||= Configuration.new
        yield(configuration)
      end
    end
    class Configuration
      attr_accessor :sender_mailer
      def def initialize
        @sender_mailer = '[email protected]'    
      end
    end
  end

  Mailer.configure do |config|
    config.sender_mailer = '[email protected]'
  end

  Mailer.configuration.sender_mailer => '[email protected]'

Reference:

  1. The easiest configuration block for your Ruby gems
  2. MyGem.configure Block