aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/class
Commit message (Collapse)AuthorAgeFilesLines
* activesupport: Simplify class_attribute implementation (#35454)Dylan Thacker-Smith2019-03-031-15/+10
| | | | | | | | * activesupport(class_attribute): Use redefine_singleton_method * activesupport(class_attribute): Use keyword arguments * activesupport(class_attribute): Avoid unnecessary redefinition for default
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* PERF: symbolize ivar, to reduce dupesSam2018-02-151-1/+1
| | | | | | | | | | | | I noticed this in my memory profiler report. ``` 153 "@default_url_options" 152 /home/sam/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.1.4/lib/active_support/core_ext/class/attribute.rb:84 ``` 152 copies of the string `@default_url_options` are retained on the heap in Discourse post boot. Since this is just used for ivar lookups there is no need to use a string.
* [Active Support] require_relative => requireAkira Matsuda2017-10-212-4/+4
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* Remove redundant require_relative "module/anonymous" and "module/reachable"bogdanvlviv2017-09-171-3/+0
|
* Clarify intentions around method redefinitionsMatthew Draper2017-09-011-14/+11
| | | | | | | | | Don't use remove_method or remove_possible_method just before a new definition: at best the purpose is unclear, and at worst it creates a race condition. Instead, prefer redefine_method when practical, and silence_redefinition_of_method otherwise.
* Merge pull request #29758 from glaucocustodio/patch-1 [ci skip]Sean Griffin2017-07-171-0/+10
|\ | | | | Add documentation for class_attribute default option
| * Add documentation for class_attribute optionsGlauco Custódio2017-07-171-0/+10
| |
* | [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-113-0/+3
|/
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-093-0/+3
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-013-6/+6
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+11
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Exclude singleton classes from `subclasses` and `descendants`Sean Griffin2016-12-011-0/+1
| | | | | | | | This behavior changed in Ruby starting with 2.3.0, as a result of https://bugs.ruby-lang.org/issues/11360. This results in a change in behavior of these methods which is likely undesirable. Fixes #27238
* [ci skip] Remove not necessary whitespaceAndrey Molchanov2016-09-281-1/+1
|
* change `Class#descendants` to public API [ci skip]yuuji.yaginuma2016-09-051-2/+15
| | | | | | `Class#descendants` has already been displayed in Rails guide, so I think that may be displayed in doc. http://guides.rubyonrails.org/active_support_core_extensions.html#descendants
* applies new string literal convention in activesupport/libXavier Noria2016-08-063-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Update class_attribute docsJohn Gesimondo2016-07-101-1/+1
|
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+0
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Test if each_object(singleton_class) works, since JRuby added it.Charles Oliver Nutter2015-11-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #22376. JRuby 9.0.5.0 will support ObjectSpace.each_object against a class's singleton class, since that's essentially just walking an internal subclasses structure we already maintain. This test was too narrow, requiring that each_object support an arbitrary class but only actually needing it to work against a class's singleton. This improves performance of Class.descendants by nearly two orders of magnitude when run against JRuby 9.0.5.0: ```ruby 5.times { puts Benchmark.measure { 100_000.times { Numeric.descendants } } } ``` Before: ``` 11.510000 0.140000 11.650000 ( 10.082384) 9.990000 0.020000 10.010000 ( 9.931233) 10.520000 0.040000 10.560000 ( 10.502978) 10.290000 0.030000 10.320000 ( 10.276027) 10.000000 0.030000 10.030000 ( 9.942429) ``` After: ``` 1.380000 0.040000 1.420000 ( 0.365850) 0.210000 0.000000 0.210000 ( 0.149574) 0.180000 0.020000 0.200000 ( 0.141094) 0.140000 0.000000 0.140000 ( 0.140634) 0.190000 0.010000 0.200000 ( 0.147962) ```
* Add Module#remove_possible_singleton_methodAndrew White2015-10-211-1/+10
| | | | | This is primarily to fix method redefinition warnings in class_attribute but may be of use in other places where we define singleton methods.
* Remove `.superclass_delegating_accessor`. Refer #14271Akshay Vishnoi2015-05-241-45/+0
|
* singleton_class? is already pressent at Ruby 2.2Rafael Mendonça França2015-01-041-8/+0
|
* Deprecate Class#superclass_delegating_accessorAkshay Vishnoi2014-03-201-0/+4
|
* Remove deprecation on active_support/core_ext/class/attribute_accessors ↵Jeremy Kemper2014-03-151-5/+3
| | | | requires. Appropriate to keep this, users don't care that the implementation got unified.
* Prevent creation of instance methods when `instance_reader = false`, Grammar ↵Akshay Vishnoi2013-12-191-8/+9
| | | | checks, Conditional statements combined
* Unify cattr and mattr accessors declarationsGenadi Samokovarov2013-12-021-180/+5
|
* Merge remote-tracking branch 'docrails/master'Xavier Noria2013-11-241-1/+1
|\ | | | | | | | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/deep_merge.rb activesupport/lib/active_support/core_ext/hash/keys.rb
| * Change syntax format for example returned valuesPrem Sichanugrist2013-11-111-1/+1
| | | | | | | | | | | | | | | | | | According to our guideline, we leave 1 space between `#` and `=>`, so we want `# =>` instead of `#=>`. Thanks to @fxn for the suggestion. [ci skip]
* | Unify `cattr_*` interface: allow to pass a block to `cattr_reader`.Alexey Chernenkov2013-11-151-0/+11
|/ | | | | | | | | Example: class A cattr_reader(:defr) { 'default_reader_value' } end A.defr # => 'default_reader_value'
* Fix `singleton_class?`Vipul A M2013-10-151-2/+5
| | | | | Due to changes from http://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39628 current `singleton_class?` implementation fails. Changed based on reference from http://bugs.ruby-lang.org/issues/7609
* Remove a comment related to 920753fRobin Dupret2013-06-261-1/+0
| | | Since 920753f, double assignment isn't used anymore
* this variable is used, so we don't have to use double assignmentsAaron Patterson2013-05-151-1/+1
|
* more descriptive NameError's messages for class attributesHrvoje Šimić2013-04-171-2/+2
|
* Add option to Class#class_attribute for skipping the query methodAgis-2013-04-061-3/+5
|
* removing out of date comment. ↵Aaron Patterson2013-03-121-3/+0
| | | | :heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart::heart: @pixeltrix
* drop memory consumption and startup speed by switching to define_methodAaron Patterson2013-03-121-23/+28
|
* Change Class#subclasses doc exampleDalibor Nasevic2013-02-061-2/+2
|
* Remove 'assigned but unused variable' warningArun Agrawal2012-12-281-1/+2
|
* Add comment about implementation of class_attributeAndrew White2012-12-061-0/+3
| | | | | | | To prevent future pull requests like #8435 add a comment about the implementation of class_attribute using class_eval for performance. [ci skip]
* Replace comments' non-breaking spaces with spacesclaudiob2012-12-041-1/+1
| | | | | | | | | | Sometimes, on Mac OS X, programmers accidentally press Option+Space rather than just Space and don’t see the difference. The problem is that Option+Space writes a non-breaking space (0XA0) rather than a normal space (0x20). This commit removes all the non-breaking spaces inadvertently introduced in the comments of the code.
* update AS/core_ext docs [ci skip]Francesco Rodriguez2012-09-121-3/+3
|
* Revert "DRY class_attribute code"José Valim2012-07-301-3/+6
| | | | | | | class_attribute is a building block and using define_method can be much slower for such basic method definitions. This reverts commit d59208d7032e2be855a89ad8d4685cc08dd7cdb3.
* DRY class_attribute codeAleksandr Zykov2012-07-291-6/+3
|
* remove :nodoc: from Class#subclasses [ci skip]Francesco Rodriguez2012-05-281-4/+10
|
* Add instance_accessor option to class_attributeAlexey Vakhov2012-05-221-2/+4
|
* cut some duplication and minor edits [ci skip]Vijay Dev2012-05-081-37/+4
|
* added docs to cattr_readerFrancesco Rodriguez2012-05-071-0/+27
|
* better docs for cattr_accessor and cattr_writerFrancesco Rodriguez2012-05-071-2/+14
|
* added docs and examples to cattr_writer methodFrancesco Rodriguez2012-05-071-5/+41
|
* added docs to cattr_accessor methodFrancesco Rodriguez2012-05-071-12/+50
|