Methods
Attributes
| [R] | attribute_names | |
| [R] | finder | |
| [R] | instantiator |
Public Class methods
[ show source ]
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 3 3: def self.match(method) 4: df_match = self.new(method) 5: df_match.finder ? df_match : nil 6: end
[ show source ]
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 8
8: def initialize(method)
9: @finder = :first
10: case method.to_s
11: when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/
12: @finder = :last if $1 == 'last_by'
13: @finder = :all if $1 == 'all_by'
14: names = $2
15: when /^find_by_([_a-zA-Z]\w*)\!$/
16: @bang = true
17: names = $1
18: when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
19: @instantiator = $1 == 'initialize' ? :new : :create
20: names = $2
21: else
22: @finder = nil
23: end
24: @attribute_names = names && names.split('_and_')
25: end
Public Instance methods
[ show source ]
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 37
37: def bang?
38: @bang
39: end
[ show source ]
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 29
29: def finder?
30: !@finder.nil? && @instantiator.nil?
31: end
[ show source ]
# File activerecord/lib/active_record/dynamic_finder_match.rb, line 33
33: def instantiator?
34: @finder == :first && !@instantiator.nil?
35: end