Refer to ActiveRecord::Base documentation for Dynamic attribute-based finders for detailed info
# File lib/active_record/dynamic_finder_match.rb, line 8
8: def self.match(method)
9: finder = :first
10: bang = false
11: instantiator = nil
12:
13: case method.to_s
14: when /^find_(all_|last_)?by_([_a-zA-Z]\w*)$/
15: finder = :last if $1 == 'last_'
16: finder = :all if $1 == 'all_'
17: names = $2
18: when /^find_by_([_a-zA-Z]\w*)\!$/
19: bang = true
20: names = $1
21: when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
22: instantiator = $1 == 'initialize' ? :new : :create
23: names = $2
24: else
25: return nil
26: end
27:
28: new(finder, instantiator, bang, names.split('_and_'))
29: end
# File lib/active_record/dynamic_finder_match.rb, line 31
31: def initialize(finder, instantiator, bang, attribute_names)
32: @finder = finder
33: @instantiator = instantiator
34: @bang = bang
35: @attribute_names = attribute_names
36: end
# File lib/active_record/dynamic_finder_match.rb, line 52
52: def bang?
53: @bang
54: end
# File lib/active_record/dynamic_finder_match.rb, line 48
48: def creator?
49: @finder == :first && @instantiator == :create
50: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.