Permalink
Browse files

Include macro name in alias method chain.

If multiple macros are defined (i.e. :image_accessor and :file_accessor) then
we get a stack overflow without this patch since both hooks define the same
chain names. Using the macro name as part of the chain name allows them to
be unique.
  • Loading branch information...
1 parent 025c38f commit 7e56e127111c95b3414867f42257250e7c2c8c0f @eric1234 committed Apr 6, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/dragonfly/app.rb
View
@@ -141,12 +141,12 @@ def define_macro_on_include(mod, macro_name)
app = self
name = self.name
(class << mod; self; end).class_eval do
- alias_method "included_without_dragonfly_#{name}", :included
- define_method "included_with_dragonfly_#{name}" do |mod|
- send "included_without_dragonfly_#{name}", mod
+ alias_method "included_without_dragonfly_#{name}_#{macro_name}", :included
+ define_method "included_with_dragonfly_#{name}_#{macro_name}" do |mod|
+ send "included_without_dragonfly_#{name}_#{macro_name}", mod
app.define_macro(mod, macro_name)
end
- alias_method :included, "included_with_dragonfly_#{name}"
+ alias_method :included, "included_with_dragonfly_#{name}_#{macro_name}"
end
end

0 comments on commit 7e56e12

Please sign in to comment.