class method
self.match
Ruby on Rails 3.1.12
Last seen in v3.2.22.5Signature
self.match(method)
No documentation comment.
Parameters
-
methodreq
Source
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 8
def self.match(method)
finder = :first
bang = false
instantiator = nil
case method.to_s
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
names = $1
when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
instantiator = $1 == 'initialize' ? :new : :create
names = $2
else
return nil
end
new(finder, instantiator, bang, names.split('_and_'))
end
Defined in activerecord/lib/active_record/dynamic_finder_match.rb line 8
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::DynamicFinderMatch