mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Delegate #model_name method to self.class
This commit is contained in:
parent
04b6ae4d18
commit
10adc2ee90
2 changed files with 12 additions and 0 deletions
|
@ -214,6 +214,12 @@ module ActiveModel
|
|||
# is required to pass the Active Model Lint test. So either extending the
|
||||
# provided method below, or rolling your own is required.
|
||||
module Naming
|
||||
def self.extended(base) #:nodoc:
|
||||
base.class_eval do
|
||||
delegate :model_name, to: :class
|
||||
end
|
||||
end
|
||||
|
||||
# Returns an ActiveModel::Name object for module. It can be
|
||||
# used to retrieve all kinds of naming-related information
|
||||
# (See ActiveModel::Name for more information).
|
||||
|
|
|
@ -272,3 +272,9 @@ class NameWithAnonymousClassTest < ActiveModel::TestCase
|
|||
assert_equal "Anonymous", model_name
|
||||
end
|
||||
end
|
||||
|
||||
class NamingMethodDelegationTest < ActiveModel::TestCase
|
||||
def test_model_name
|
||||
assert_equal Blog::Post.model_name, Blog::Post.new.model_name
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue