W3cubDocs

/Ruby on Rails 4.2

module ActiveRecord::DynamicMatchers::Finder

Public Instance Methods

attributes_hash() Show source

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

# File activerecord/lib/active_record/dynamic_matchers.rb, line 101
def attributes_hash
  "{" + attribute_names.map { |name| ":#{name} => _#{name}" }.join(',') + "}"
end
body() Show source

Extended in activerecord-deprecated_finders

# File activerecord/lib/active_record/dynamic_matchers.rb, line 82
def body
  result
end
finder() Show source
# File activerecord/lib/active_record/dynamic_matchers.rb, line 105
def finder
  raise NotImplementedError
end
result() Show source

Extended in activerecord-deprecated_finders

# File activerecord/lib/active_record/dynamic_matchers.rb, line 87
def result
  "#{finder}(#{attributes_hash})"
end
signature() Show source

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

# File activerecord/lib/active_record/dynamic_matchers.rb, line 95
def signature
  attribute_names.map { |name| "_#{name}" }.join(', ')
end

© 2004–2017 David Heinemeier Hansson
Licensed under the MIT License.