Skip to content
This repository has been archived by the owner on Jun 22, 2020. It is now read-only.

Commit

Permalink
Break out the current_theme method into two parts to fix some of the …
Browse files Browse the repository at this point in the history
…ActionMailer integration
  • Loading branch information
James Stewart committed Apr 25, 2009
1 parent fb8088e commit 16b57d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 3 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
10 changes: 6 additions & 4 deletions lib/patches/actioncontroller_ex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
8 changes: 1 addition & 7 deletions lib/patches/actionmailer_ex.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -90,8 +87,5 @@ def create!(method_name, *parameters) #:nodoc:
# build the mail object itself
@mail = create_mail
end



end
end

0 comments on commit 16b57d5

Please sign in to comment.