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] | attribute_names | |
[R] | finder | |
[R] | instantiator |
Class Public methods
# 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 %r^find_(all_|last_)?by_([_a-zA-Z]\w*)$/ finder = :last if $1 == 'last_' finder = :all if $1 == 'all_' names = $2 when %r^find_by_([_a-zA-Z]\w*)\!$/ bang = true names = $1 when %r^find_or_create_by_([_a-zA-Z]\w*)\!$/ bang = true instantiator = :create names = $1 when %r^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
Instance Public methods