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:       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_(initialize|create)_by_([_a-zA-Z]\w*)$/
22:         instantiator = $1 == 'initialize' ? :new : :create
23:         names = $2
24:       else
25:         return nil
26:       end
27: 
28:       new(finder, instantiator, bang, names.split('_and_'))
29:     end
new(finder, instantiator, bang, attribute_names) click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 31
31:     def initialize(finder, instantiator, bang, attribute_names)
32:       @finder          = finder
33:       @instantiator    = instantiator
34:       @bang            = bang
35:       @attribute_names = attribute_names
36:     end

Public Instance Methods

bang?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 52
52:     def bang?
53:       @bang
54:     end
creator?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 48
48:     def creator?
49:       @finder == :first && @instantiator == :create
50:     end
finder?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 40
40:     def finder?
41:       @finder && !@instantiator
42:     end
instantiator?() click to toggle source
    # File lib/active_record/dynamic_finder_match.rb, line 44
44:     def instantiator?
45:       @finder == :first && @instantiator
46:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.