Allow ActiveSupport::Deprecation features to be used by rails applications and library authors#6348
Allow ActiveSupport::Deprecation features to be used by rails applications and library authors#6348carlosantoniodasilva merged 2 commits intorails:masterfrom LTe:no_global_depreactations
Conversation
|
|
@jeremy done :) |
There was a problem hiding this comment.
Should probably leave these as a constant since it acts as public API now. People add behaviors to this hash directly.
|
@LTe Very nice! Looking good. |
There was a problem hiding this comment.
Typo: . instead of , after NEW_CONST.
|
@carlosantoniodasilva @jeremy thanks for feedback! |
|
What do you think about it: module ActiveSupport
class Deprecation
def initialize(horizon = '3.2', gem_name = 'rails')
self.deprecation_horizon = horizon
self.gem_name = gem_name
end
end
endFor custom gems authors should create new instances of These: deprecator = ActiveSupport::Deprecation.new
deprecator.deprecation_horizon = "2.0.0"ActiveSupport::Deprecation.new.tap{|d| d.deprecation_horizon = "2.0.0" }seem to be unnecessary verbose to me. ActiveSupport::Deprecation.new("2.0.0", "formtastic")looks much better imho. |
|
Science Fiction: module ActiveSupport
class Deprecation
def initialize(horizon = default_horizon, gem_name = 'rails')
self.deprecation_horizon = horizon
self.gem_name = gem_name
end
def default_horizon
"#{ActiveSupport::VERSION::MAJOR}.#{ActiveSupport::VERSION::MINOR + 1}"
end
end
endbecause sometimes it should be |
|
Now you can create About science fiction I think better solution is pass directly version to initialize method. |
|
"About science fiction I think better solution is pass directly version to initialize method." - probably. Except for the fact that the core team needs to change this one line every time there is new rails version. I wanted to spare them this trouble in this science fiction solution :) |
|
According to http://semver.org/ this always should be |
|
@jeremy what do you think? We can merge current implementation? |
|
@jeremy updated and rebased |
|
@LTe some comments on the documentation :) It covers how to give a custom deprecator object, but doesn't show how you can use When I read through the duck type for a deprecator, having to implement two methods seems wrong, too. We call |
|
@jeremy - I think that's because |
|
@paneq definitely -- and a higher-level method like |
|
Updated |
|
@jeremy what do you think about merge? |
|
@LTe it needs rebased at least, it can't be merged cleanly anymore. |
|
@steveklabnik rebased ;-) |
|
Thanks. Let's see what @jeremy says. |
|
What do you think @jeremy ? |
|
👍 |
There was a problem hiding this comment.
Please remove whitespaces between the method and class declaration, there's no need for them ✂️
|
@LTe hey, could you please add a changelog entry for this, and check the minor comments I made, so that we can get this in master? Thanks! |
|
@carlosantoniodasilva updated, rebased. |
|
@LTe, great thanks. I'll have to ask you one more thing though, to review your commit message and improve the changelog a bit with an example of how to use this new feature. This will help others to understand the reasoning and how to use the feature at the same time when reading the commits or the changelog. Here's an explanation about how to go with the commit message, and here's another about changelogs. I'll merge it afterwards. Thanks! |
…xtend/include it also. test local deprecation deprecator object Test ActiveSupport::Deprecation when included
ActiveSupport::Deprecation is now a class rather than a module. You can get instance of ActiveSupport::Deprecation calling #instance method. ActiveSupport::Deprecation.instance But when you need to get new object od ActiveSupport::Deprecation you need to just call #new. @instance = ActiveSupport::Deprecation.new Since you can create a new object, you can change the version and the name of the library where the deprecator concerned. ActiveSupport::Deprecation.new('2.0', 'MyGem') If you need use another deprecator instance you can select it in the options of deprecate method. deprecate :method, :deprecator => deprecator_instance Documentation has been updated.
|
@carlosantoniodasilva updated |
|
@LTe great, thank you! |
Allow ActiveSupport::Deprecation features to be used by rails applications and library authors
Updated version of #2310