Skip to content

Commit

Permalink
ActiveModel::Naming delegate match? in the same manner as =~ and != (#…
Browse files Browse the repository at this point in the history
…33466)

The purpose of the module seems to quack like a string.
  • Loading branch information
bdewater authored and kaspth committed Jul 29, 2018
1 parent 66da5ea commit eb4f7ca
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion activemodel/lib/active_model/naming.rb
Expand Up @@ -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
#
Expand All @@ -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+
Expand Down

0 comments on commit eb4f7ca

Please sign in to comment.