title: Rails 3 Engine - Provide Config For Users
body: <p>I can't seem to find any documentation on how to do the following: I need to provide a config variable for any applications using my engine so that they can easily pass settings to my engine.</p>
  
  <p>Does anyone have any links to a proper or accepted way to do this?</p>
  
  <p><strong>EDIT:</strong> As an update, I figured out a decent way to do this. Code is below.</p>
  
  <pre><code># file: lib/my_engine.rb
  module MyEngine
  
    class Engine &lt; Rails::Engine
  
      initializer "my_engine.configure_rails_initialization" do |app|
        # Engine configures Rails app here, this is not what my question was about
      end
  
    end
  
    # This is what I was trying to figure out
    def self.config(&amp;block)
      @@config ||= MyEngine::Configuration.new
  
      yield @@config if block
  
      return @@config
    end
  
  end
  </code></pre>
  
  <p>This allows any application using my engine to configure it like below in any of their initializers or their environment.rb file, calling any methods defined in the <code>MyEngine::Configuration</code> class:</p>
  
  <pre><code>MyEngine.config do |config|
    config.some_configuration_option = "Whatever"
  end
  </code></pre>