My favorites
▼
|
Sign in
substruct
Open-source Ruby on Rails E-Commerce
Project Home
Downloads
Wiki
Issues
Source
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
11
attachment: substruct_deprecated.rb
(838 bytes)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class SubstructDeprecated < StandardError; end
def substruct_deprecated(message=nil)
$substruct_deprecated ||= {}
deprecated_method = caller[0].gsub(/.*\`(.*)\'.*/,'\1')
called_from = caller[1].gsub(%r{.*/\.\.\/(.*)$},'\1')
warning = "Deprecation warning: #{deprecated_method} called from #{called_from}. #{message}"
unless ($substruct_deprecated[warning])
RAILS_DEFAULT_LOGGER.error "\n**** #{warning} ****\n"
$substruct_deprecated[warning] = true
end
if ENV['RAILS_ENV'] == 'test'
raise SubstructDeprecated, warning
end
end
class Module
def substruct_deprecate(from_old_to_new)
from_old_to_new.each do |old_name, new_name|
define_method(old_name) do |*args|
substruct_deprecated "Use #{new_name} instead of #{old_name}"
send(new_name, *args)
end
end
end
end
Powered by
Google Project Hosting