I’m putting together a plugin and it has to monkey-patch some of
ActionMailer. A good deal of AM’s magic is class methods, and I’m
wanting to
do something like:
module ActionMailer
class Base
class << self
def create!(method_name, *parameters)
puts “yippee, skippee, I got here!”
# do something useful
end
end
end
end
So, I go ahead and do this, hoping to simply drop my create! in over
ActionMailer’s, but in my tests, the ActionMailer code is called and not
mine.
Can anyone tell me what I’m missing here?
The technique is OK, you probably knew this, so next thing to look at
is which class is being loaded later, that one is the winner.
Yeah, I finally got it… The way AM is constructed is somewhat
complicated so I had one detail wrong and it led me to the wrong
conclusion: that I had syntactically screwed up.
I announced the plugin on the Haml list because it applies to templating
languages other than rhtml, but here’s a redux of the announcement:
I just put a plugin together specifically to make ActionMailer play nice
with Haml. It also will work with Markaby or any other “unsupported”
markup
language.
Initially, this code was s’posed to be a Rails patch, but it keeps not
showing up in trunk, so here it is as a plugin. You can read about it
here:
There is no Trac or anything, but your can email me with bugs or
comments
(and be gentle).
longinos wrote:
Yeah, I finally got it… The way AM is constructed is somewhat
complicated so I had one detail wrong and it led me to the wrong
conclusion: that I had syntactically screwed up.
For educational reasons would you mind posting the “clean” code?
Thanks!
Shawn
Steve R. wrote:
Yeah, I finally got it… The way AM is constructed is somewhat
complicated so I had one detail wrong and it led me to the wrong
conclusion: that I had syntactically screwed up.
Thx,
–sr
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.