Hello, I'm looking for feedback on a possible pull-request to rails.
Here's the idea: right now any time an ActiveModel::Name is needed, it is accessed through model.class.model_name.
In other words, currently, it's something like this:
# Somewhere in rails
model.class.model_name
class MyModel
def self.model_name
ActiveModel::Name.new(self)
end
endAnd I'd like it to be like this:
# Somewhere in rails
model.model_name
class MyModel
def self.model_name
ActiveModel::Name.new(self)
end
delegate :model_name, to: :'self.class'
endHere's a gist of what inspired me to try going this direction: https://gist.github.com/3096204
So, here's where I started: https://github.com/amiel/rails/commit/a64e5b4ccf9e851b06cd2eb64d824a9c2043c6e7
My initial questions are:
- Do you think this is a good idea? Also, I'm surprised this hasn't been done already, have I missed a rejected pull request?
- How should the instance method
model_namebe added to ActiveModel classes? The class methodmodel_nameis provided byextendingActiveModel::Naming. Is it appropriate to use theextendedhook inActiveModel::Namingto either include another module or use define_method? - What are some arguments for or against the change? I'm mostly looking for arguments for the change to include in the pull request description, but I'm also curious what the arguments against would be.