deprecations 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -22
- data/deprecations.gemspec +26 -0
- data/lib/deprecations/version.rb +1 -1
- data/lib/deprecations.rb +164 -9
- metadata +14 -18
- data/lib/deprecations/behavior.rb +0 -69
- data/lib/deprecations/extension.rb +0 -77
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d4cdbe0575ac1d02430ffc3e88c32688824d9ba47dbaaf3bc67608174a24e319
|
|
4
|
+
data.tar.gz: 22c9ed6e63fcdd3b6eb5fa287326e87e1bd7598a033748b7869d139c6c56be35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a7c9d6706072053a2c4fade7a96c7aa4c86c986d77cb71bbad346778b6c041fcc9a4e3cc1e57750bd081341f353e7c2069e5c16df8af81a8f5f9df682040f45
|
|
7
|
+
data.tar.gz: 1f8658e34eefb696079867af2e71534758ca0af650484d84b4249e797094d42e33587374764037b25daca616a97a2ebdbb8554e34ac3f95bcb5618d38f64d6a9
|
data/README.md
CHANGED
|
@@ -2,27 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This gem provides transparent declaration of deprecated methods and classes. It's easy, small, has no dependencies and no overhead.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
The simplest way to install Deprecations gem is to use [Bundler](http://gembundler.com/).
|
|
8
|
-
|
|
9
|
-
Add Deprecations to your `Gemfile`:
|
|
10
|
-
|
|
11
|
-
```ruby
|
|
12
|
-
gem 'deprecations'
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
and install it by running Bundler:
|
|
16
|
-
|
|
17
|
-
```shell
|
|
18
|
-
$ bundle add deprecations
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
To install the gem globally use:
|
|
22
|
-
|
|
23
|
-
```shell
|
|
24
|
-
$ gem install deprecations
|
|
25
|
-
```
|
|
5
|
+
- Gem: [rubygems.org](https://rubygems.org/gems/deprecations)
|
|
6
|
+
- Source: [codeberg.org](https://codeberg.org/mblumtritt/deprecations)
|
|
26
7
|
|
|
27
8
|
## Usage
|
|
28
9
|
|
|
@@ -70,9 +51,10 @@ Deprecations.behavior = :raise
|
|
|
70
51
|
|
|
71
52
|
There are 3 pre-defined behaviors:
|
|
72
53
|
|
|
73
|
-
- `:raise` will raise an `
|
|
54
|
+
- `:raise` will raise an `Deprecations::Exception` when a deprecated method is called
|
|
74
55
|
- `:silence` will do nothing (ignore the deprecation)
|
|
75
56
|
- `:warn` will print a warning (default behavior)
|
|
57
|
+
- `:deprecated` will print a warning when Ruby's warning category 'deprecated' is enabled
|
|
76
58
|
|
|
77
59
|
Besides this you can implement your own:
|
|
78
60
|
|
|
@@ -92,3 +74,23 @@ Deprecations.with_behavior(:silent) { MyDeprecatedClass.new.do_some_magic }
|
|
|
92
74
|
```
|
|
93
75
|
|
|
94
76
|
Please have a look at the [specs](https://github.com/mblumtritt/deprecations/blob/master/spec/deprecations_spec.rb) for detailed information and more samples.
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
You can install the gem in your system with
|
|
81
|
+
|
|
82
|
+
```shell
|
|
83
|
+
gem install deprecations
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
or you can use [Bundler](http://gembundler.com/) to add Terminal.rb to your own project:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
bundle add deprecations
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
After that you only need one line of code to have everything together
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
require 'deprecations'
|
|
96
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/deprecations/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'deprecations'
|
|
7
|
+
spec.version = Deprecations::VERSION
|
|
8
|
+
spec.summary = 'Deprecation support for your project.'
|
|
9
|
+
spec.description = <<~DESCRIPTION.tr("\n", ' ')
|
|
10
|
+
This gem provides transparent declaration of deprecated methods and classes.
|
|
11
|
+
It's easy, small, has no dependencies and no overhead.
|
|
12
|
+
DESCRIPTION
|
|
13
|
+
|
|
14
|
+
spec.author = 'Mike Blumtritt'
|
|
15
|
+
spec.licenses = %w[MIT Ruby]
|
|
16
|
+
spec.homepage = 'https://codeberg.org/mblumtritt/deprecations'
|
|
17
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
|
|
19
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
20
|
+
|
|
21
|
+
spec.required_ruby_version = '> 3.0'
|
|
22
|
+
|
|
23
|
+
spec.files = Dir['lib/**/*.rb']
|
|
24
|
+
spec.files += %w[deprecations.gemspec]
|
|
25
|
+
spec.extra_rdoc_files = %w[README.md]
|
|
26
|
+
end
|
data/lib/deprecations/version.rb
CHANGED
data/lib/deprecations.rb
CHANGED
|
@@ -1,18 +1,173 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Deprecations
|
|
4
|
-
require_relative 'deprecations/behavior'
|
|
5
|
-
require_relative 'deprecations/extension'
|
|
6
|
-
require_relative 'deprecations/version'
|
|
7
|
-
|
|
8
4
|
Error = Class.new(ScriptError)
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
class << self
|
|
7
|
+
def behavior = BEHAVIOR.key(@behavior) || @behavior
|
|
8
|
+
|
|
9
|
+
def behavior=(value)
|
|
10
|
+
@behavior = as_behavior(value)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def with_behavior(behavior)
|
|
14
|
+
current_behavior = @behavior
|
|
15
|
+
@behavior = as_behavior(behavior)
|
|
16
|
+
yield if block_given?
|
|
17
|
+
ensure
|
|
18
|
+
@behavior = current_behavior
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
alias set_behavior with_behavior
|
|
22
|
+
|
|
23
|
+
def call(subject, alternative, outdated)
|
|
24
|
+
@behavior.call(subject, alternative, outdated)
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def as_behavior(arg)
|
|
31
|
+
return arg if defined?(arg.call)
|
|
32
|
+
BEHAVIOR.fetch(arg) do
|
|
33
|
+
raise(
|
|
34
|
+
ArgumentError,
|
|
35
|
+
"invalid parameter - behavior has to be #{
|
|
36
|
+
BEHAVIOR.keys.map(&:inspect).join(' | ')
|
|
37
|
+
} or need to respond to `#call`"
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def name_error(exc)
|
|
43
|
+
exc.set_backtrace(exc.backtrace.drop_while { _1.start_with?(__FILE__) })
|
|
44
|
+
exc
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
module Raise
|
|
49
|
+
def self.call(subject, alternative, _outdated)
|
|
50
|
+
error =
|
|
51
|
+
Error.new(
|
|
52
|
+
"`#{subject}` is deprecated#{
|
|
53
|
+
" - use #{alternative} instead" if alternative
|
|
54
|
+
}"
|
|
55
|
+
)
|
|
56
|
+
error.set_backtrace(caller(3))
|
|
57
|
+
raise(error)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
module WarnMessage
|
|
62
|
+
def message(subject, alternative, outdated)
|
|
63
|
+
"`#{subject}` is deprecated#{
|
|
64
|
+
outdated ? " and will be outdated #{outdated}." : '.'
|
|
65
|
+
}#{" Please use `#{alternative}` instead." if alternative}"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
module Warn
|
|
70
|
+
extend WarnMessage
|
|
71
|
+
|
|
72
|
+
def self.call(*args) = ::Kernel.warn(message(*args), uplevel: 3)
|
|
13
73
|
end
|
|
14
74
|
|
|
75
|
+
module Deprecated
|
|
76
|
+
extend WarnMessage
|
|
77
|
+
|
|
78
|
+
def self.call(*args)
|
|
79
|
+
::Kernel.warn(message(*args), uplevel: 3, category: :deprecated)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
BEHAVIOR = {
|
|
84
|
+
silence: proc {},
|
|
85
|
+
raise: Raise,
|
|
86
|
+
warn: Warn,
|
|
87
|
+
deprecated: Deprecated
|
|
88
|
+
}.freeze
|
|
89
|
+
|
|
90
|
+
module ClassMethods
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def deprecated(name, alt = nil, outdated = nil)
|
|
94
|
+
alias_name = "__deprecated__singleton_method__#{name}__"
|
|
95
|
+
return if private_method_defined?(alias_name)
|
|
96
|
+
begin
|
|
97
|
+
alias_method(alias_name, name)
|
|
98
|
+
rescue NameError => e
|
|
99
|
+
raise ::Deprecations.__send__(:name_error, e)
|
|
100
|
+
end
|
|
101
|
+
private(alias_name)
|
|
102
|
+
if alt.is_a?(Symbol)
|
|
103
|
+
begin
|
|
104
|
+
alt = instance_method(alt)
|
|
105
|
+
rescue NameError => e
|
|
106
|
+
raise ::Deprecations.__send__(:name_error, e)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
define_method(name) do |*args, **kw_args, &b|
|
|
110
|
+
::Deprecations.call(
|
|
111
|
+
"#{self}.#{::Kernel.__method__}",
|
|
112
|
+
(alt.is_a?(UnboundMethod) ? "#{self}.#{alt.name}" : alt),
|
|
113
|
+
outdated
|
|
114
|
+
)
|
|
115
|
+
__send__(alias_name, *args, **kw_args, &b)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
module InstanceMethods
|
|
121
|
+
private
|
|
122
|
+
|
|
123
|
+
def deprecated(name, alt = nil, outdated = nil)
|
|
124
|
+
alias_name = "__deprecated__instance_method__#{name}__"
|
|
125
|
+
return if private_method_defined?(alias_name)
|
|
126
|
+
begin
|
|
127
|
+
alias_method(alias_name, name)
|
|
128
|
+
rescue NameError => e
|
|
129
|
+
::Deprecations.__send__(:name_error, e)
|
|
130
|
+
return singleton_class.__send__(:deprecated, name, alt, outdated)
|
|
131
|
+
end
|
|
132
|
+
private(alias_name)
|
|
133
|
+
if alt.is_a?(Symbol)
|
|
134
|
+
begin
|
|
135
|
+
alt = instance_method(alt)
|
|
136
|
+
rescue NameError => e
|
|
137
|
+
raise ::Deprecations.__send__(:name_error, e)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
define_method(name) do |*args, **kw_args, &b|
|
|
141
|
+
pref =
|
|
142
|
+
if defined?(self.class.name)
|
|
143
|
+
self.class.name
|
|
144
|
+
else
|
|
145
|
+
::Kernel.instance_method(:class).bind(self).call
|
|
146
|
+
end
|
|
147
|
+
::Deprecations.call(
|
|
148
|
+
"#{pref}##{::Kernel.__method__}",
|
|
149
|
+
(alt.is_a?(UnboundMethod) ? "#{pref}##{alt.name}" : alt),
|
|
150
|
+
outdated
|
|
151
|
+
)
|
|
152
|
+
__send__(alias_name, *args, **kw_args, &b)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def deprecated!(alternative = nil, outdated = nil)
|
|
157
|
+
org = method(:new)
|
|
158
|
+
define_singleton_method(:new) do |*args, **kw_args, &b|
|
|
159
|
+
::Deprecations.call(name, alternative, outdated)
|
|
160
|
+
org.call(*args, **kw_args, &b)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
Module.extend(ClassMethods)
|
|
166
|
+
Module.include(InstanceMethods)
|
|
167
|
+
|
|
168
|
+
autoload :VERSION, "#{__dir__}/deprecations/version.rb"
|
|
169
|
+
|
|
170
|
+
private_constant(*(constants - %i[Error VERSION]))
|
|
171
|
+
|
|
15
172
|
self.behavior = :warn
|
|
16
173
|
end
|
|
17
|
-
|
|
18
|
-
DeprecationError = Deprecations::Error
|
metadata
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deprecations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Blumtritt
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
|
|
15
|
-
It's easy, small, has no dependencies and no overhead.
|
|
16
|
-
email:
|
|
12
|
+
description: 'This gem provides transparent declaration of deprecated methods and
|
|
13
|
+
classes. It''s easy, small, has no dependencies and no overhead. '
|
|
17
14
|
executables: []
|
|
18
15
|
extensions: []
|
|
19
16
|
extra_rdoc_files:
|
|
20
17
|
- README.md
|
|
21
18
|
files:
|
|
22
19
|
- README.md
|
|
20
|
+
- deprecations.gemspec
|
|
23
21
|
- lib/deprecations.rb
|
|
24
|
-
- lib/deprecations/behavior.rb
|
|
25
|
-
- lib/deprecations/extension.rb
|
|
26
22
|
- lib/deprecations/version.rb
|
|
27
|
-
homepage: https://
|
|
28
|
-
licenses:
|
|
23
|
+
homepage: https://codeberg.org/mblumtritt/deprecations
|
|
24
|
+
licenses:
|
|
25
|
+
- MIT
|
|
26
|
+
- Ruby
|
|
29
27
|
metadata:
|
|
30
|
-
source_code_uri: https://
|
|
31
|
-
bug_tracker_uri: https://
|
|
28
|
+
source_code_uri: https://codeberg.org/mblumtritt/deprecations
|
|
29
|
+
bug_tracker_uri: https://codeberg.org/mblumtritt/deprecations/issues
|
|
32
30
|
rubygems_mfa_required: 'true'
|
|
33
|
-
post_install_message:
|
|
34
31
|
rdoc_options: []
|
|
35
32
|
require_paths:
|
|
36
33
|
- lib
|
|
37
34
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
35
|
requirements:
|
|
39
|
-
- - "
|
|
36
|
+
- - ">"
|
|
40
37
|
- !ruby/object:Gem::Version
|
|
41
|
-
version:
|
|
38
|
+
version: '3.0'
|
|
42
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
40
|
requirements:
|
|
44
41
|
- - ">="
|
|
45
42
|
- !ruby/object:Gem::Version
|
|
46
43
|
version: '0'
|
|
47
44
|
requirements: []
|
|
48
|
-
rubygems_version: 3.
|
|
49
|
-
signing_key:
|
|
45
|
+
rubygems_version: 3.6.9
|
|
50
46
|
specification_version: 4
|
|
51
47
|
summary: Deprecation support for your project.
|
|
52
48
|
test_files: []
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Deprecations
|
|
4
|
-
class << self
|
|
5
|
-
def behavior
|
|
6
|
-
BEHAVIOR.key(@behavior) || @behavior
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def behavior=(value)
|
|
10
|
-
@behavior = as_behavior(value)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def with_behavior(behavior)
|
|
14
|
-
behavior = as_behavior(behavior)
|
|
15
|
-
raise(ArgumentError, 'block expected') unless block_given?
|
|
16
|
-
current_behavior = @behavior
|
|
17
|
-
@behavior = behavior
|
|
18
|
-
yield
|
|
19
|
-
ensure
|
|
20
|
-
@behavior = current_behavior if current_behavior
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
alias set_behavior with_behavior
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def as_behavior(arg)
|
|
28
|
-
return arg if defined?(arg.call)
|
|
29
|
-
BEHAVIOR.fetch(arg) do
|
|
30
|
-
raise(
|
|
31
|
-
ArgumentError,
|
|
32
|
-
'invalid parameter - behavior has to be ' \
|
|
33
|
-
"#{valid_behaviors} or need to respond to `#call`"
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def valid_behaviors
|
|
39
|
-
BEHAVIOR.keys.map(&:inspect).join(' | ')
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
module Raise
|
|
43
|
-
def self.call(subject, alternative, _outdated)
|
|
44
|
-
raise(
|
|
45
|
-
Error
|
|
46
|
-
.new(
|
|
47
|
-
"`#{subject}` is deprecated#{
|
|
48
|
-
" - use #{alternative} instead" if alternative
|
|
49
|
-
}"
|
|
50
|
-
)
|
|
51
|
-
.tap { |error| error.set_backtrace(caller(3)) }
|
|
52
|
-
)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
module Warn
|
|
57
|
-
def self.call(subject, alternative, outdated)
|
|
58
|
-
::Kernel.warn(
|
|
59
|
-
"`#{subject}` is deprecated#{
|
|
60
|
-
outdated ? " and will be outdated #{outdated}." : '.'
|
|
61
|
-
}#{" Please use `#{alternative}` instead." if alternative}",
|
|
62
|
-
uplevel: 3
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
BEHAVIOR = { silence: proc {}, raise: Raise, warn: Warn }.freeze
|
|
68
|
-
end
|
|
69
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Deprecations
|
|
4
|
-
private_class_method def self.infect(mod)
|
|
5
|
-
mod.extend(ClassMethods)
|
|
6
|
-
mod.__send__(:include, InstanceMethods)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
module ClassMethods
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def deprecated(method_name, alternative = nil, outdated = nil)
|
|
13
|
-
alias_name = "__deprecated__singleton_method__#{method_name}__"
|
|
14
|
-
return if private_method_defined?(alias_name)
|
|
15
|
-
alias_method(alias_name, method_name)
|
|
16
|
-
private(alias_name)
|
|
17
|
-
alternative = instance_method(alternative) if alternative.is_a?(Symbol)
|
|
18
|
-
define_method(method_name) do |*args, **kw_args, &b|
|
|
19
|
-
Deprecations.call(
|
|
20
|
-
"#{self}.#{::Kernel.__method__}",
|
|
21
|
-
if alternative.is_a?(UnboundMethod)
|
|
22
|
-
"#{self}.#{alternative.name}"
|
|
23
|
-
else
|
|
24
|
-
alternative
|
|
25
|
-
end,
|
|
26
|
-
outdated
|
|
27
|
-
)
|
|
28
|
-
__send__(alias_name, *args, **kw_args, &b)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
module InstanceMethods
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def deprecated(method_name, alternative = nil, outdated = nil)
|
|
37
|
-
alias_name = "__deprecated__instance_method__#{method_name}__"
|
|
38
|
-
return if private_method_defined?(alias_name)
|
|
39
|
-
alias_method(alias_name, method_name)
|
|
40
|
-
private(alias_name)
|
|
41
|
-
alternative = instance_method(alternative) if alternative.is_a?(Symbol)
|
|
42
|
-
define_method(method_name) do |*args, **kw_args, &b|
|
|
43
|
-
pref =
|
|
44
|
-
if defined?(self.class.name)
|
|
45
|
-
self.class.name
|
|
46
|
-
else
|
|
47
|
-
Kernel.instance_method(:class).bind(self).call
|
|
48
|
-
end
|
|
49
|
-
Deprecations.call(
|
|
50
|
-
"#{pref}##{::Kernel.__method__}",
|
|
51
|
-
if alternative.is_a?(UnboundMethod)
|
|
52
|
-
"#{pref}##{alternative.name}"
|
|
53
|
-
else
|
|
54
|
-
alternative
|
|
55
|
-
end,
|
|
56
|
-
outdated
|
|
57
|
-
)
|
|
58
|
-
__send__(alias_name, *args, **kw_args, &b)
|
|
59
|
-
end
|
|
60
|
-
rescue NameError
|
|
61
|
-
raise if private_method_defined?(alias_name)
|
|
62
|
-
singleton_class.__send__(:deprecated, method_name, alternative, outdated)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def deprecated!(alternative = nil, outdated = nil)
|
|
66
|
-
org = method(:new)
|
|
67
|
-
define_singleton_method(:new) do |*args, **kw_args, &b|
|
|
68
|
-
Deprecations.call(name, alternative, outdated)
|
|
69
|
-
org.call(*args, **kw_args, &b)
|
|
70
|
-
end
|
|
71
|
-
rescue NameError
|
|
72
|
-
nil
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
infect(Module)
|
|
77
|
-
end
|