Parent

Files

Class Index [+]

Quicksearch

ActiveRecord::DynamicFinderMatch

Active Record Dynamic Finder Match

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

Attributes

finder[R]
attribute_names[R]
instantiator[R]

Public Class Methods

match(method) click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 8
 8:     def self.match(method)
 9:       df_match = self.new(method)
10:       df_match.finder ? df_match : nil
11:     end
new(method) click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 13
13:     def initialize(method)
14:       @finder = :first
15:       @bang   = false
16:       @instantiator = nil
17: 
18:       case method.to_s
19:       when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/
20:         @finder = :last if $1 == 'last_by'
21:         @finder = :all if $1 == 'all_by'
22:         names = $2
23:       when /^find_by_([_a-zA-Z]\w*)\!$/
24:         @bang = true
25:         names = $1
26:       when /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/
27:         @instantiator = $1 == 'initialize' ? :new : :create
28:         names = $2
29:       else
30:         @finder = nil
31:       end
32:       @attribute_names = names && names.split('_and_')
33:     end

Public Instance Methods

bang?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 49
49:     def bang?
50:       @bang
51:     end
creator?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 45
45:     def creator?
46:       @finder == :first && @instantiator == :create
47:     end
finder?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 37
37:     def finder?
38:       !@finder.nil? && @instantiator.nil?
39:     end
instantiator?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 41
41:     def instantiator?
42:       @finder == :first && !@instantiator.nil?
43:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.