модуль ActiveRecord::DynamicMatchers::Finder
Публичные методы экземпляра
# File activerecord/lib/active_record/dynamic_matchers.rb, line 101
def attributes_hash
"{" + attribute_names.map { |name| ":#{name} => _#{name}" }.join(',') + "}"
end Если параметры начинаются с `_`, поиск должен использовать то же имя параметра.
# File activerecord/lib/active_record/dynamic_matchers.rb, line 82 def body result end
Расширено в activerecord-deprecated_finders
# File activerecord/lib/active_record/dynamic_matchers.rb, line 105 def finder raise NotImplementedError end
# File activerecord/lib/active_record/dynamic_matchers.rb, line 87
def result
"#{finder}(#{attributes_hash})"
end Расширено в activerecord-deprecated_finders
# File activerecord/lib/active_record/dynamic_matchers.rb, line 95
def signature
attribute_names.map { |name| "_#{name}" }.join(', ')
end Параметры в сигнатуре могут содержать зарезервированные слова Ruby, для предотвращения ошибок, мы начинаем каждое имя параметра с `_`.
Расширено в activerecord-deprecated_finders
© 2004–2018 David Heinemeier Hansson
Licensed under the MIT License.