Skip to content

Commit

Permalink
Refactor ActionMailer to not use hide_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
drogus committed Sep 3, 2010
1 parent 4131a2d commit 79bd92b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 69 deletions.
1 change: 1 addition & 0 deletions actionmailer/lib/action_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

require 'abstract_controller'
require 'action_view'
require 'action_dispatch'

# Common Active Support usage in Action Mailer
require 'active_support/core_ext/class'
Expand Down
11 changes: 3 additions & 8 deletions actionmailer/lib/action_mailer/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/proc'
require 'action_mailer/log_subscriber'
require 'action_mailer/hide_actions'

module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
Expand Down Expand Up @@ -341,13 +340,13 @@ class Base < AbstractController::Base
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
include AbstractController::UrlFor

cattr_reader :protected_instance_variables
@@protected_instance_variables = []

helper ActionMailer::MailHelper
include ActionMailer::OldApi
include ActionMailer::HideActions

delegate :register_observer, :to => Mail
delegate :register_interceptor, :to => Mail
Expand All @@ -364,9 +363,8 @@ class Base < AbstractController::Base

class << self
def inherited(klass)
klass.with_hiding_actions do
super(klass)
end
super(klass)
klass.class_eval { @action_methods = nil }
end

def mailer_name
Expand Down Expand Up @@ -732,9 +730,6 @@ def insert_part(container, response, charset) #:nodoc:
container.add_part(part)
end

class_attribute :default_url_options
self.default_url_options = {}

ActiveSupport.run_load_hooks(:action_mailer, self)
end
end
46 changes: 0 additions & 46 deletions actionmailer/lib/action_mailer/hide_actions.rb

This file was deleted.

1 change: 1 addition & 0 deletions actionpack/lib/abstract_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ module AbstractController
autoload :Translation
autoload :AssetPaths
autoload :ViewPaths
autoload :UrlFor
end
28 changes: 28 additions & 0 deletions actionpack/lib/abstract_controller/url_for.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module AbstractController
module UrlFor
extend ActiveSupport::Concern

include ActionDispatch::Routing::UrlFor

def _routes
raise "In order to use #url_for, you must include routing helpers explicitly. " \
"For instance, `include Rails.application.routes.url_helpers"
end

module ClassMethods
def _routes
nil
end

def action_methods
@action_methods ||= begin
if _routes
super - _routes.named_routes.helper_names
else
super
end
end
end
end
end
end
15 changes: 1 addition & 14 deletions actionpack/lib/action_controller/metal/url_for.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActionController
module UrlFor
extend ActiveSupport::Concern

include ActionDispatch::Routing::UrlFor
include AbstractController::UrlFor

def url_options
options = {}
Expand All @@ -16,18 +16,5 @@ def url_options
:_path_segments => request.symbolized_path_parameters
)
end

def _routes
raise "In order to use #url_for, you must include routing helpers explicitly. " \
"For instance, `include Rails.application.routes.url_helpers"
end

module ClassMethods
def action_methods
@action_methods ||= begin
super - _routes.named_routes.helper_names
end
end
end
end
end
7 changes: 6 additions & 1 deletion actionpack/lib/action_dispatch/routing/route_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ class << self
# Yes plz - JP
included do
routes.install_helpers(self)
singleton_class.send(:define_method, :_routes) { @_routes || routes }
singleton_class.send(:define_method, :_routes) { routes }
end

def initialize(*)
@_routes = nil
super
end

define_method(:_routes) { @_routes || routes }
Expand Down

0 comments on commit 79bd92b

Please sign in to comment.