Active Record Dynamic Finder Match

Refer to ActiveRecord::Base documentation for Dynamic attribute-based finders for detailed info

Methods
B
C
F
I
M
N
S
Attributes
[R] finder
[R] attribute_names
[R] instantiator
Class Public methods
match(method)
    # File activerecord/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_create_by_([_a-zA-Z]\w*)\!$/
22:         bang = true
23:         instantiator = :create
24:         names = $1
25:       when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
26:         instantiator = $1 == 'initialize' ? :new : :create
27:         names = $2
28:       else
29:         return nil
30:       end
31: 
32:       new(finder, instantiator, bang, names.split('_and_'))
33:     end
new(finder, instantiator, bang, attribute_names)
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 35
35:     def initialize(finder, instantiator, bang, attribute_names)
36:       @finder          = finder
37:       @instantiator    = instantiator
38:       @bang            = bang
39:       @attribute_names = attribute_names
40:     end
Instance Public methods
bang?()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 56
56:     def bang?
57:       @bang
58:     end
creator?()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 52
52:     def creator?
53:       @finder == :first && @instantiator == :create
54:     end
finder?()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 44
44:     def finder?
45:       @finder && !@instantiator
46:     end
instantiator?()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 48
48:     def instantiator?
49:       @finder == :first && @instantiator
50:     end
save_method()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 64
64:     def save_method
65:       bang? ? :save! : :save
66:     end
save_record?()
    # File activerecord/lib/active_record/dynamic_finder_match.rb, line 60
60:     def save_record?
61:       @instantiator == :create
62:     end