ActiveModel::Naming delegate match? in the same manner as =~ and != (#33466)
The purpose of the module seems to quack like a string.
This commit is contained in:
parent
66da5ea128
commit
eb4f7cad20
@ -110,6 +110,22 @@ class Name
|
||||
# BlogPost.model_name.eql?('BlogPost') # => true
|
||||
# BlogPost.model_name.eql?('Blog Post') # => false
|
||||
|
||||
##
|
||||
# :method: match?
|
||||
#
|
||||
# :call-seq:
|
||||
# match?(regexp)
|
||||
#
|
||||
# Equivalent to <tt>String#match?</tt>. Match the class name against the
|
||||
# given regexp. Returns +true+ if there is a match, otherwise +false+.
|
||||
#
|
||||
# class BlogPost
|
||||
# extend ActiveModel::Naming
|
||||
# end
|
||||
#
|
||||
# BlogPost.model_name.match?(/Post/) # => true
|
||||
# BlogPost.model_name.match?(/\d/) # => false
|
||||
|
||||
##
|
||||
# :method: to_s
|
||||
#
|
||||
@ -131,7 +147,7 @@ class Name
|
||||
# to_str()
|
||||
#
|
||||
# Equivalent to +to_s+.
|
||||
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s,
|
||||
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :match?, :to_s,
|
||||
:to_str, :as_json, to: :name
|
||||
|
||||
# Returns a new ActiveModel::Name instance. By default, the +namespace+
|
||||
|
Loading…
Reference in New Issue
Block a user