Skip to content

Commit

Permalink
Allow loading of only specific Rails modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Aug 30, 2011
1 parent 232b113 commit f7a72f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
15 changes: 9 additions & 6 deletions lib/combustion.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
require 'rails'
require 'active_support/dependencies'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'

module Combustion
def self.initialize!
Modules = %w( active_record action_controller action_view action_mailer
sprockets )

def self.initialize!(*modules)
modules = Modules if modules.empty? || modules == [:all]
modules.each { |mod| require "#{mod}/railtie" }

Combustion::Application.configure_for_combustion
Combustion::Application.initialize!

silence_stream(STDOUT) do
Expand All @@ -18,7 +21,7 @@ def self.initialize!

config.include(Combustion::Application.routes.url_helpers)
config.include(Combustion::Application.routes.mounted_helpers)
end if defined?(RSpec)
end if defined?(RSpec) && RSpec.respond_to?(:configure)
end
end

Expand Down
26 changes: 17 additions & 9 deletions lib/combustion/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ class Combustion::Application < Rails::Application
# ActiveSupport Settings
config.active_support.deprecation = :stderr

# Action Controller and Action Dispatch
config.action_dispatch.show_exceptions = false
config.action_controller.perform_caching = false
config.action_controller.allow_forgery_protection = false
# Some settings we're not sure if we want, so let's not load them by default.
# Instead, wait for this method to be invoked (to get around load-order
# complications).
def self.configure_for_combustion
if defined?(ActionController) && defined?(ActionController::Engine)
config.action_dispatch.show_exceptions = false
config.action_controller.perform_caching = false
config.action_controller.allow_forgery_protection = false
end

# Action Mailer Settings
# config.action_mailer.delivery_method = :test
# config.action_mailer.default_url_options = {:host => 'www.example.com'}
if defined?(ActionMailer) && defined?(ActionMailer::Engine)
config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = {:host => 'www.example.com'}
end

# Asset Settings
config.assets.enabled = true
if defined?(Sprockets)
config.assets.enabled = true
end
end
end

0 comments on commit f7a72f5

Please sign in to comment.