Permalink
Browse files

DRY up our regular expression

  • Loading branch information...
tenderlove committed Sep 27, 2010
1 parent 10d9740 commit 1efeb5c9351e8ba546d2c43f06c4cc8f3eade848
Showing with 3 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/dynamic_finder_match.rb
@@ -16,9 +16,9 @@ def initialize(method)
@instantiator = nil
case method.to_s
- when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/
- @finder = :last if $1 == 'last_by'
- @finder = :all if $1 == 'all_by'
+ when /^find_(all_|last_)?by_([_a-zA-Z]\w*)$/
+ @finder = :last if $1 == 'last_'
+ @finder = :all if $1 == 'all_'
names = $2
when /^find_by_([_a-zA-Z]\w*)\!$/
@bang = true

0 comments on commit 1efeb5c

Please sign in to comment.