aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/dynamic_matchers.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Fix rubocop offencesRyuta Kamizono2019-04-301-2/+2
|
* Rename local variable `n` to `name`Ryuta Kamizono2019-04-241-1/+1
|
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* `respond_to_missing?` should be privateRyuta Kamizono2017-04-221-9/+8
| | | | | | | Follow up of 03d3f036. Some of `respond_to?` were replaced to `respond_to_missing?` in 03d3f036. But the visibility is still public. It should be private.
* :scissors:Ryuta Kamizono2017-04-131-1/+0
| | | | [ci skip]
* let Regexp#match? be globally availableXavier Noria2016-10-271-1/+0
| | | | | | Regexp#match? should be considered to be part of the Ruby core library. We are emulating it for < 2.4, but not having to require the extension is part of the illusion of the emulation.
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-4/+4
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-4/+4
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Override `respond_to_missing?` instead of `respond_to?` when possibleSean Griffin2016-08-311-1/+1
| | | | | | | | | | This was almost every case where we are overriding `respond_to?` in a way that mirrors a parallel implementation of `method_missing`. There is one remaining case in Active Model that should probably do the same thing, but had a sufficiently strange implementation that I want to investigate it separately. Fixes #26333.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-74/+74
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* adds missing requiresXavier Noria2016-07-241-0/+2
|
* systematic revision of =~ usage in ARXavier Noria2016-07-231-1/+1
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* Revert "Merge pull request #20080 from ↵Rafael Mendonça França2015-09-091-3/+3
| | | | | | | | | robertjlooby/fix_overwriting_by_dynamic_finders" This reverts commit d5ba9a42a6e93b163a49f99d739aa56820e044d0, reversing changes made to 30c503395bf6bf7db1ec0295bd661ce644628db5. Reason: This generate the dynalic finders more than one time
* put dynamic matchers on the GeneratedAssociationMethods instead of modelRob Looby2015-05-081-3/+3
|
* Remove support to activerecord-deprecated_findersRafael Mendonça França2015-01-021-20/+1
|
* Fixed a bug in AR::Base#respond_to?Godfrey Chan2014-01-291-2/+6
| | | | | | | | | | | | Before: >> ActiveRecord::Base.respond_to?(:find_by_something) NoMethodError: undefined method `abstract_class?' for Object:Class After: >> ActiveRecord::Base.respond_to?(:find_by_something) => false
* Prevent invalid code when using dynamic finders with Ruby's reserved words.Lauro Caetano2013-12-111-2/+7
| | | | | | | | | | | | | | | | | | | | | The dynamic finder was creating the method signature with the parameters name, which may have reserved words and this way creating invalid Ruby code. Closes: #13261 Example: # Before Dog.find_by_alias('dog name') # Was creating this method def self.find_by_alias(alias, options = {}) # After Dog.find_by_alias('dog name') # Will create this method def self.find_by_alias(_alias, options = {})
* Avoid compiling regexs in AR::Base.respond_to?John Hawthorn2013-08-211-1/+1
| | | | | Caches the patterns of ActiveRecord::DynamicMatchers in a class instance variable.
* removes redundant requireXavier Noria2013-02-251-2/+0
| | | | It turns out this file is required in active_record.rb.
* AR loads activerecord-deprecated_finders, no need to add it to the GemfileXavier Noria2013-02-251-0/+2
|
* Renaming active_record_deprecated_finders to activerecord-deprecated_findersJon Leighton2012-08-171-5/+5
| | | | For consistency with the other AR extension plugins we are creating.
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-1/+1
| | | | | | | | | | | This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
* made dynamic finders alias_attribute awareMaximilian Schneider2012-06-221-0/+1
| | | | | previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* extract deprecated dynamic methodsJon Leighton2012-05-041-140/+38
|
* actually don't need to expand the aggregates at allJon Leighton2012-05-041-11/+1
|
* #to_sym is unnecessaryJon Leighton2012-05-041-3/+3
|
* de-globalise methodJon Leighton2012-05-041-8/+1
|
* extract code from AR::BaseJon Leighton2012-05-041-32/+28
|
* clean up implementation of dynamic methods. use method compilation etc.Jon Leighton2012-05-041-29/+199
|
* Refactor and cleanup in some ActiveRecord modulesCarlos Antonio da Silva2012-03-031-19/+23
| | | | | | | | | | | * Avoid double hash lookups in AR::Reflection when reflecting associations/aggregations * Minor cleanups: use elsif, do..end, if..else instead of unless..else * Simplify DynamicMatchers#respond_to? * Use "where" instead of scoped with conditions hash * Extract `scoped_by` method pattern regexp to constant * Extract noisy class_eval from method_missing in dynamic matchers * Extract readonly check, avoid calling column#to_s twice in persistence * Refactor predicate builder, remove some variables
* Move argument validation into matchPaul McMahon2012-01-281-1/+1
|
* Fix regression from Rails 3.1Paul McMahon2012-01-271-1/+1
| | | | | | Under Rails 3.1, you were allowed to pass a hash to a find_or_create method with multiple attribute names, but this was broken as the arguments were being improperly validated.
* Split out most of the AR::Base code into separate modules :cake:Jon Leighton2011-12-151-0/+79