123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::DynamicMatchers::Finder

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: activerecord/lib/active_record/dynamic_matchers.rb

Instance Method Summary

  • #attributes_hash

    Given that the parameters starts with _, the finder needs to use the same parameter name.

  • #body

    Extended in activerecord-deprecated_finders.

  • #finder
  • #result

    Extended in activerecord-deprecated_finders.

  • #signature

    The parameters in the signature may have reserved Ruby words, in order to prevent errors, we start each param name with _.

Instance Method Details

#attributes_hash

Given that the parameters starts with _, the finder needs to use the same parameter name.

[ GitHub ]

  
# File 'activerecord/lib/active_record/dynamic_matchers.rb', line 101

def attributes_hash
  "{" + attribute_names.map { |name| ":#{name} => _#{name}" }.join(',') + "}"
end

#body

Extended in activerecord-deprecated_finders

[ GitHub ]

  
# File 'activerecord/lib/active_record/dynamic_matchers.rb', line 82

def body
  result
end

#finder

Raises:

  • (NotImplementedError)
[ GitHub ]

  
# File 'activerecord/lib/active_record/dynamic_matchers.rb', line 105

def finder
  raise NotImplementedError
end

#result

Extended in activerecord-deprecated_finders

[ GitHub ]

  
# File 'activerecord/lib/active_record/dynamic_matchers.rb', line 87

def result
  "#{finder}(#{attributes_hash})"
end

#signature

The parameters in the signature may have reserved Ruby words, in order to prevent errors, we start each param name with _.

Extended in activerecord-deprecated_finders

[ GitHub ]

  
# File 'activerecord/lib/active_record/dynamic_matchers.rb', line 95

def signature
  attribute_names.map { |name| "_#{name}" }.join(', ')
end