diff --git a/init.rb b/init.rb index e5d87a9..30afc0e 100755 --- a/init.rb +++ b/init.rb @@ -4,6 +4,9 @@ require 'patches/actionmailer_ex' require 'patches/routeset_ex' +ActionController::Base.send(:include, ThemeSupport::ControllerExtensions) +ActionMailer::Base.send(:include, ThemeSupport::ControllerExtensions) + # Add the tag helpers for rhtml and, optionally, liquid templates require 'helpers/rhtml_theme_tags' diff --git a/lib/patches/actioncontroller_ex.rb b/lib/patches/actioncontroller_ex.rb index 026995b..a4fbf7a 100755 --- a/lib/patches/actioncontroller_ex.rb +++ b/lib/patches/actioncontroller_ex.rb @@ -32,7 +32,12 @@ module InstanceMethods attr_accessor :force_liquid_template # Retrieves the current set theme - def current_theme(passed_theme=nil) + + def current_theme(passed_theme = nil) + @current_theme ||= get_current_theme(passed_theme) + end + + def get_current_theme(passed_theme=nil) theme = passed_theme || self.class.read_inheritable_attribute("theme") @active_theme = case theme @@ -58,6 +63,3 @@ def active_layout(passed_layout = nil, options = {}) end end end - -ActionMailer::Base.send(:include, ThemeSupport::ControllerExtensions) -ActionController::Base.send(:include, ThemeSupport::ControllerExtensions) \ No newline at end of file diff --git a/lib/patches/actionmailer_ex.rb b/lib/patches/actionmailer_ex.rb index bf53711..65bf758 100755 --- a/lib/patches/actionmailer_ex.rb +++ b/lib/patches/actionmailer_ex.rb @@ -1,9 +1,6 @@ -# Extend the Base ActionController to support themes +# Extend the Base ActionMailer to support themes module ActionMailer class Base - - alias_method :__render, :render - alias_method :__initialize, :initialize def initialize(method_name=nil, *parameters) if parameters[-1].is_a?(Hash) and (parameters[-1].include? :theme) @@ -90,8 +87,5 @@ def create!(method_name, *parameters) #:nodoc: # build the mail object itself @mail = create_mail end - - - end end \ No newline at end of file