aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
Commit message (Collapse)AuthorAgeFilesLines
* Adjust `Module.parent_name` to work when frozen; fixes #27637Corey Ward2017-01-171-2/+4
|
* Merge pull request #26480 from tbrisker/fix-26461Rafael França2017-01-041-2/+7
|\ | | | | Clarify that mattr_* creates public methods
| * Reword according to feedbackTomer Brisker2016-09-151-8/+7
| |
| * Clarify that mattr_* creates public methodsTomer Brisker2016-09-131-0/+6
| |
* | split DELEGATION_RESERVED_METHOD_NAMES in halfToshimaru2016-12-091-4/+5
| |
* | Remove deprecated method alias_method_chainAndrew White2016-11-141-48/+0
| |
* | Remove deprecated Module.qualified_const_get/set/defined?Andrew White2016-11-141-70/+0
| |
* | Remove deprecated module method_transplanting fileAndrew White2016-11-131-3/+0
| |
* | Remove deprecated local_constantsAndrew White2016-11-131-8/+0
| |
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
| |
* | doc, hide non-public methods form the api docs. [ci skip]Yves Senn2016-10-201-2/+2
|/ | | | | | | | | This is a follow up to #25681, specifically this comment: https://github.com/rails/rails/pull/25681#issuecomment-238294002 The way the thread local variable is stored is an implementation detail and subject to change. It makes no sense to only generate a reader or writer as you'd have to know where to read from or where it writes to.
* Fix typo in Delegation#delegate_missing_to doc [skip ci]Anton Davydov2016-08-271-1/+1
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Merge pull request #25570 from y-yagi/remove_useless_parameterEileen M. Uchitelle2016-08-151-3/+3
|\ | | | | remove useless parameter
| * remove useless parameteryuuji.yaginuma2016-06-291-4/+4
| |
* | let instance thread_mattr_* methods delegate to the class-level onesXavier Noria2016-08-081-4/+10
| | | | | | | | | | | | | | This code has too much duplication and the rationale for the concatenation may not be obvious to the reader. You define the ones at class-level, explain why does the code concatenates there, and then the convenience ones at instance-level just delegate.
* | Merge pull request #25681 from willnet/fix-thread_mattr_accessorYves Senn2016-08-081-4/+4
|\ \ | | | | | | | | | Fix `thread_mattr_accessor` share variable superclass with subclass
| * | Fix `thread_mattr_accessor` share variable superclass with subclasswillnet2016-08-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of `thread_mattr_accessor` set variable sharing superclass with subclass. So the method doesn't work as documented. Precondition class Account thread_mattr_accessor :user end class Customer < Account end Account.user = "DHH" Account.user #=> "DHH" Customer.user = "Rafael" Customer.user # => "Rafael" Documented behavior Account.user # => "DHH" Actual behavior Account.user # => "Rafael" Current implementation set variable statically likes `Thread[:attr_Account_user]`, and customer also use it. Make variable name dynamic to use own thread-local variable.
* | | damn typos [ci skip]Xavier Noria2016-08-081-1/+1
| | |
* | | explain why aliasing uses explicit selfs [ci skip]Xavier Noria2016-08-081-0/+3
| | |
* | | applies new string literal convention in activesupport/libXavier Noria2016-08-0610-24/+24
|/ / | | | | | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* / systematic revision of =~ usage in ASXavier Noria2016-07-223-7/+10
|/ | | | | Where appropriate prefer the more concise Regexp#match?, String#include?, String#start_with?, and String#end_with?
* Replace Kernel#caller by the faster Kernel#caller_locationsJean Boussier2016-06-101-2/+2
|
* [skip ci] Fix grammarAbhishek Jain2016-06-031-2/+2
|
* Don't delegate to private methods of the targerRafael Mendonça França2016-05-241-1/+5
| | | | 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-1/+60
|\ | | | | | | Introduce Module#delegate_missing_to
| * Introduce Module#delegate_missing_toGenadi Samokovarov2016-02-271-1/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Update delegate to use newer Ruby syntaxTodd Lynam2016-04-201-5/+2
| | | | | | This commit updates `delegate` to use the keyword argument syntax added in Ruby 2. I left the `ArgumentError` when `to` is missing, because it better explains how to correctly use `delegate`. We could instead rely on the default `ArgumentError` that would be raised if `to` were a required keyword argument.
* | fixed spelling in the attribute_accessors docuTorsten Braun2016-03-231-1/+1
| | | | | | mattr_writer to mattr_reader
* | fixed spellin in the mattr_reader documentationTorsten Braun2016-03-231-1/+1
| | | | | | renamed cattr_reader to mattr_reader
* | Fix `thread_mattr_accessor` thread-local variable namingMichael Ryan2016-03-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implentation of `thread_mattr_accessor` is setting differently-named thread variables when defining class and instance writer methods, so the method isn't working as documented: Account.user = "DHH" Account.user # => "DHH" Account.new.user # => nil a = Account.new a.user = "ABC" # => "ABC" a.class.user # => "DHH" At this point `:attr_Account_user` and `:attr_Class_user` thread-local variables have been created. Modify the reader and writer methods to use the class name instead of 'Class'.
* | Deprecate `Module.local_constants`yui-knk2016-03-011-0/+4
|/ | | | | After Ruby 1.9, we can easily get the constants that have been defined locally by `Module.constants(false)`.
* :arrow_left: indentationAkira Matsuda2016-01-281-2/+2
| | | | [ci-skip]
* Fix documentation for mattr_accessor methodsJan Habermann2015-12-201-6/+6
|
* [ci skip] Revert most of ff851017Kasper Timm Hansen2015-12-181-2/+2
| | | We went back to `Thread.current[]` in 33e11e59.
* Revert "Use Thread.current.thread_variable_set/get insetad of the direct ↵David Heinemeier Hansson2015-12-181-4/+4
| | | | | | accessors" This reverts commit 301f43820562c6a70dffe30f4227ff0751f47d4f per @matthewd on https://github.com/rails/rails/pull/22630/files#r47997074
* [ci skip] Add `Thread.current` to match internalsKasper Timm Hansen2015-12-171-2/+2
| | | | | | | | We call the thread variable accessors on `Thread.current`, which matches Ruby's documentation: http://ruby-doc.org/core-2.2.0/Thread.html#method-i-thread_variable_get Fix these to stay `current` ( ͡° ͜ʖ ͡°)
* Clarify thread_mattr_accessor subclass behavior documentationNate Berkopec2015-12-171-8/+9
| | | | [ci skip]
* Copy-edit the Per Thread attribute accessor documentationRafael Mendonça França2015-12-171-3/+3
| | | | [ci skip]
* Use Thread.current.thread_variable_set/get insetad of the direct accessorsDavid Heinemeier Hansson2015-12-171-4/+4
|
* Fix typo in thread_mattr_accessor doco [ci skip]Nate Berkopec2015-12-171-1/+1
|
* Add thread_m/cattr_accessor/reader/writer suite of methods for declaring ↵David Heinemeier Hansson2015-12-171-0/+140
| | | | class and module variables that live per-thread
* Don't leak Object constants in core_ext/module/qualified_constGenadi Samokovarov2015-12-161-12/+30
|
* Minor fix in Module#mattr_reader documentationYuri Kasperovich2015-11-091-1/+1
|
* Make `Module#redefine_method` to keep method visibilityyui-knk2015-10-261-0/+13
| | | | | | | Before this commit `Module#redefine_method` always changes visibility of redefined method to `public`. This commit changes behavior of Module#redefine_method` to keep method visibility.
* [ci skip] Add more code examples for `Module#anonymous?` docsyui-knk2015-10-231-2/+4
| | | | | In later code examples, it is better to write how `Module#anonymous?` works.
* Add Module#remove_possible_singleton_methodAndrew White2015-10-211-0/+7
| | | | | This is primarily to fix method redefinition warnings in class_attribute but may be of use in other places where we define singleton methods.
* Merge pull request #21302 from theunraveler/delegate_reserved_argument_namesSean Griffin2015-10-201-5/+6
|\ | | | | ActiveSupport: Fixing issue when delegating to methods named "block", "args", or "arg"
| * Fixing issue when delegating to methods named "block", "args", or "arg"Jake Bell2015-08-191-5/+6
| |
* | Regex fix for mattr_accessor validationAliaksandr Buhayeu2015-10-011-2/+2
| | | | | | | | | | Change ^ and $ operators to \A and \z to prevent code injection after the line breaks