aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Remove deprecated method alias_method_chainAndrew White2016-11-141-215/+0
|
* Remove deprecated local_constantsAndrew White2016-11-131-10/+0
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-25/+25
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-35/+35
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add test for `delegate_missing_to` where method doesn't existJon Moss2016-05-261-0/+8
|
* Add tests for keyword arg to: for Module#delegateYosuke Kabuto2016-05-251-0/+15
|
* Don't delegate to private methods of the targerRafael Mendonça França2016-05-241-0/+14
| | | | And make sure that it doesn't even try to call the method in the target.
* Merge pull request #23930 from gsamokovarov/module-delegate-missing-toRafael Mendonça França2016-05-241-0/+22
|\ | | | | | | Introduce Module#delegate_missing_to
| * Introduce Module#delegate_missing_toGenadi Samokovarov2016-02-271-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building decorators, a common pattern may emerge: class Partition def initialize(first_event) @events = [ first_event ] end def people if @events.first.detail.people.any? @events.collect { |e| Array(e.detail.people) }.flatten.uniq else @events.collect(&:creator).uniq end end private def respond_to_missing?(name, include_private = false) @events.respond_to?(name, include_private) end def method_missing(method, *args, &block) @events.send(method, *args, &block) end end With `Module#delegate_missing_to`, the above is condensed to: class Partition delegate_missing_to :@events def initialize(first_event) @events = [ first_event ] end def people if @events.first.detail.people.any? @events.collect { |e| Array(e.detail.people) }.flatten.uniq else @events.collect(&:creator).uniq end end end David suggested it in #23824.
* | Remove duplicated `test_` prefix [ci skip]Ryuta Kamizono2016-03-021-1/+1
| |
* | Deprecate `Module.local_constants`yui-knk2016-03-011-1/+7
|/ | | | | After Ruby 1.9, we can easily get the constants that have been defined locally by `Module.constants(false)`.
* Fixing issue when delegating to methods named "block", "args", or "arg"Jake Bell2015-08-191-0/+15
|
* Deprecate alias_method_chain in favour of Module#prependKir Shatrov2015-03-221-95/+125
| | | …as discussed #19413
* Revert 88d08f2ec9f89ba431cba8d0c06ac9ebc204bbbbRafael Mendonça França2015-02-111-1/+1
| | | | | | | This caused a performance regression since we were decided to do the nil check in run time not in the load time. See https://github.com/rails/rails/pull/15187#issuecomment-71760058
* Delegation works with reserved words passed to `:to`Agis-2014-09-191-0/+11
| | | | Fixes #16956.
* Fix confusing exception in ActiveSupport delegationVladimir Yarotsky2014-05-201-1/+1
|
* Remove warningRafael Mendonça França2014-01-161-2/+2
|
* define the delegate methods on one line. fixes #13724Aaron Patterson2014-01-161-0/+10
| | | | sup haters
* Unused classes in AS testsAkira Matsuda2013-12-191-6/+0
|
* Only raise DelegationError if it's is the source of the exceptionAndrew White2013-07-111-0/+27
| | | | | | | | | This fixes situations where nested NoMethodError exceptions are masked by delegations. This would cause confusion especially where there was a problem in the Rails booting process because of a delegation in the routes reloading code. Fixes #10559
* Fixed test broken by local_constant_names Arun Agrawal2013-07-031-6/+0
| | | depreciation removed
* Move delegation error constant to inside ModuleCarlos Antonio da Silva2013-06-261-1/+1
|
* Add DelegationError class. Rasied by delegation to a nil objectSteve Faulkner2013-06-261-1/+1
|
* Module#delegate checks nilness rather that falsehood if :allow_nil is true, ↵Xavier Noria2013-04-261-0/+31
| | | | | | | | | | | | | | and avoids multiple evaluation of the target method Notes: 1) I hope nilness is a word. 2) See rationale for avoiding multiple evaluation in a comment in the patch, credit goes to @jeremy for pointing out this gotcha in the existing implementation. 3) Embeds a little joke dedicated to @pixeltrix (it could be worse! :D). References #10347.
* Delegation method bugLi Ellis Gallardo2013-04-251-0/+5
| | | | | | Add documentation and test to delegation method that make sure we're aware that when a delegated object is not nil or false and doesn't respond to the method it will still raise a NoMethodError exception.
* Nice and easy delegation to the classMarc-Andre Lafortune2012-09-111-0/+11
|
* JRuby return different Array for module contents.Arun Agrawal2012-05-291-1/+1
| | | | | Test was failing against JRuby. It loads like [Constant3 Constant1]
* Optimize the performance of #delegateDaniel Schierbeck2012-04-121-0/+19
| | | | | | Remove the use of #__send__ in order to boost performance. This also means that you can no longer delegate to private methods on the target object.
* deprecates Module#local_constant_namesXavier Noria2012-01-121-0/+6
|
* use AS::TestCase as the base classAaron Patterson2012-01-051-2/+2
|
* We can't simply check the first line of the backtrace, Arun Agrawal2011-09-041-4/+6
| | | because JRuby reports the call to __send__ in the backtrace.
* Revert all the stuff to do with disallowing non-public methods for ↵Jon Leighton2011-08-251-19/+1
| | | | Module#delegate
* Add a test for delegating a method ending in '=' as this is a special case.Jon Leighton2011-08-151-0/+8
|
* Split up the definitions in Module#delegate depending on :allow_nil, and ↵Jon Leighton2011-08-151-0/+12
| | | | don't use exceptions for flow control in the :allow_nil => true case.
* Fix the line number in the backtrace when Module#delegate raisesJon Leighton2011-08-151-1/+13
|
* Just do the method call directly in Module#delegate, if we can (we cannot ↵Jon Leighton2011-08-151-2/+20
| | | | for method names ending in '='). Two reasons: 1) it's faster, see https://gist.github.com/1089783 and 2) more importantly, delegate should not allow you to accidentally call private or protected methods.
* Remove unused line in test setup.Ben Orenstein2011-02-171-1/+0
| | | | | | [#6442 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Remove unused code.Ben Orenstein2011-02-161-3/+0
| | | | | | [#6437 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* delegate method should treat :prefix => false same as :prefix => nilNeeraj Singh2010-09-011-0/+13
| | | | | | [#5375 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Removes unused varsSantiago Pastorino2010-07-241-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-5/+5
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Singleton classes returns parent's methods with instance_methods(false) and ↵José Valim2010-03-191-0/+14
| | | | this makes remove_method in Module#delegate fail. Add a test case and fix the bug.
* Fix test ordering bug related to introducing masked Name classYehuda Katz2010-02-191-14/+6
|
* removes Module#as_load_path, which is no longer usedXavier Noria2010-02-071-5/+0
|
* removes Module#included_in_classes, which is no longer usedXavier Noria2010-02-071-7/+0
|
* Allow delegating to nil, because the method might actually exist on itBryan Helmkamp2009-08-101-1/+12
|