Object
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_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
# File 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
# File lib/active_record/dynamic_finder_match.rb, line 56 56: def bang? 57: @bang 58: end
# File lib/active_record/dynamic_finder_match.rb, line 52 52: def creator? 53: @finder == :first && @instantiator == :create 54: end
# File lib/active_record/dynamic_finder_match.rb, line 44 44: def finder? 45: @finder && !@instantiator 46: end
# File lib/active_record/dynamic_finder_match.rb, line 48 48: def instantiator? 49: @finder == :first && @instantiator 50: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.