Permalink
Browse files

Demonstrating Engine configuration in host app initializer

  • Loading branch information...
Brandon Tilley
Brandon Tilley committed Feb 17, 2012
1 parent 7dd8a0b commit e1ff21940c2bc257ffc88b9f10e9ee40891ea64f
@@ -1,5 +1,5 @@
class Mountie::TestController < Mountie::ApplicationController
def index
- render text: "Testing"
+ render text: Mountie.configuration.name
end
end
View
@@ -1,5 +1,22 @@
+require 'ostruct'
+
module Mountie
+ @configuration = OpenStruct.new(name: '')
+
+ class << self
+ attr_reader :configuration
+ def configure
+ yield @configuration
+ end
+ end
+
class Engine < ::Rails::Engine
isolate_namespace Mountie
+
+ initializer "something" do |app|
+ # Demonstrates that the host application's initializer
+ # has already run by the time this is called.
+ puts Mountie.configuration.inspect
+ end
end
end
@@ -0,0 +1,3 @@
+Mountie.configure do |config|
+ config.name = "This is a test"
+end

0 comments on commit e1ff219

Please sign in to comment.