diff options
author | Bart <bartdewater@gmail.com> | 2018-07-29 13:58:35 -0400 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2018-07-29 19:58:35 +0200 |
commit | eb4f7cad2087ea9365da36938784bcb80696a9d8 (patch) | |
tree | fd25c428f5aee110d2eff4deb36093aa8b24b11c /activemodel/lib | |
parent | 66da5ea1286c2a3b428a18546f7f076722218bd4 (diff) | |
download | rails-eb4f7cad2087ea9365da36938784bcb80696a9d8.tar.gz rails-eb4f7cad2087ea9365da36938784bcb80696a9d8.tar.bz2 rails-eb4f7cad2087ea9365da36938784bcb80696a9d8.zip |
ActiveModel::Naming delegate match? in the same manner as =~ and != (#33466)
The purpose of the module seems to quack like a string.
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/naming.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index dfccd03cd8..983401801f 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -111,6 +111,22 @@ module ActiveModel # 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 # # :call-seq: @@ -131,7 +147,7 @@ module ActiveModel # 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+ |