Tuesday, March 18, 2008

alias_method for class methods

class Login
def self.super_user
system_admin = Role.find_by_desc("system_admin")
find(:first,
:conditions => "permissions.role_id = #{system_admin.id}",
:include => :permissions)
end

class << self
alias_method :system_admin, :super_user
end
end


Some links:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/60494
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/60487
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/60489

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/255814

No comments: