diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-06 10:44:30 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-06 10:44:30 -0700 |
commit | a9da54988f11bf79e7df2275397aca468092ea05 (patch) | |
tree | 1f2ca6e74ab30bbc9a13ccd5e09426d77004a4e3 /activesupport/lib/active_support/core_ext | |
parent | ec8f59ca530316a14672686611c629abc4112950 (diff) | |
parent | 666a248b0c38ceb93a4dc2da76e28b0cbd7283df (diff) | |
download | rails-a9da54988f11bf79e7df2275397aca468092ea05.tar.gz rails-a9da54988f11bf79e7df2275397aca468092ea05.tar.bz2 rails-a9da54988f11bf79e7df2275397aca468092ea05.zip |
Merge pull request #10113 from Agis-/default_scopes_predicate
Deprecate ActiveRecord#Base.default_scopes?
Closes #10107
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/attribute.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index e51ab9ddbc..6d49b7b6e1 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -44,7 +44,8 @@ class Class # Base.setting # => [] # Subclass.setting # => [:foo] # - # For convenience, a query method is defined as well: + # For convenience, an instance predicate method is defined as well. + # To skip it, pass <tt>instance_predicate: false</tt>. # # Subclass.setting? # => false # @@ -72,10 +73,11 @@ class Class # double assignment is used to avoid "assigned but unused variable" warning instance_reader = instance_reader = options.fetch(:instance_accessor, true) && options.fetch(:instance_reader, true) instance_writer = options.fetch(:instance_accessor, true) && options.fetch(:instance_writer, true) + instance_predicate = options.fetch(:instance_predicate, true) attrs.each do |name| define_singleton_method(name) { nil } - define_singleton_method("#{name}?") { !!public_send(name) } + define_singleton_method("#{name}?") { !!public_send(name) } if instance_predicate ivar = "@#{name}" @@ -109,7 +111,7 @@ class Class self.class.public_send name end end - define_method("#{name}?") { !!public_send(name) } + define_method("#{name}?") { !!public_send(name) } if instance_predicate end attr_writer name if instance_writer |