alias throwing exception: undefined method `send_mail' for class`HeartBeat' (NameError)

T

Tristin Davis

[Note: parts of this message were removed to make it a legal post.]

I'm having a problem with the code below. when I try and alias the
send_mail method, it throws an exception.

undefined method `send_mail' for class `HeartBeat' (NameError)

Any help would be appreciated. :)


class Heartbeat

alias :win_mail :send_mail if RUBY_PLATFORM =~ /mswin32/
alias :unix_mail :send_mail if RUBY_PLATFORM =~ /linux/

#Abstract method
def send_mail
raise RuntimeError, "Could not detect OS"
end

private

# in: hash=> subject, body, recipients
# out: true if successful
def win_mail(opts={})
require 'win32ole'
outlook = WIN32OLE.new('Outlook.Application')
message = outlook.CreateItem(0)
message.Subject = opts[:subject]
message.Body = opts[:body]
message.To = opts[:recipients]
message.Send
end

def unix_mail(opts={})
end

end
 
M

Mikael Høilund

I'm having a problem with the code below. when I try and alias the
send_mail method, it throws an exception.

undefined method `send_mail' for class `HeartBeat' (NameError)

Any help would be appreciated. :)


class Heartbeat

alias :win_mail :send_mail if RUBY_PLATFORM =~ /mswin32/
alias :unix_mail :send_mail if RUBY_PLATFORM =~ /linux/

#Abstract method
def send_mail
raise RuntimeError, "Could not detect OS"
end

The method isn't defined in the class until now. Move the alias lines
to below the def, and it'll work.

--
a,b=%Q=Z,O^NPO\r4_PV\\PI\x15^-\x0\v=,email=%\%%%c\%115%%# Mikael
Hoilund, CTO
okay=%#;hmm=(0...a.size).map{|i|((a-email+2)%128).# of Meta.io
ApS from
chr}.join;!email.gsub!'o',"%c%c"%[3+?0.<<(2),?G.~@];aha=#############
Denmark
hmm.scan(/#{'(.)'*5}/);!puts(email[1..-12]+aha.shift.zip(*aha).join)#
Ruby <3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top