aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-08-04 16:23:22 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-08-04 16:23:22 -0300
commit23f902c05fa51a29a26e7afce1db2de475e1c8d6 (patch)
tree3c2cf75c0f3eb6d59afe02fd4cdcd9cd33263660
parent7521b8ec3ab14d25d93f11a185e387a69e8f6375 (diff)
downloadrails-23f902c05fa51a29a26e7afce1db2de475e1c8d6.tar.gz
rails-23f902c05fa51a29a26e7afce1db2de475e1c8d6.tar.bz2
rails-23f902c05fa51a29a26e7afce1db2de475e1c8d6.zip
Only define Objetc#itself when it is not defined
Ruby 2.2 will include Kernel#itself so we don't need to define again. See https://github.com/ruby/ruby/commit/0a0160d6b659f6131a525fe1579e7c463d4c197e
-rw-r--r--activesupport/lib/active_support/core_ext/object/itself.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/itself.rb b/activesupport/lib/active_support/core_ext/object/itself.rb
index df613c4e4f..90cd6b1c57 100644
--- a/activesupport/lib/active_support/core_ext/object/itself.rb
+++ b/activesupport/lib/active_support/core_ext/object/itself.rb
@@ -1,10 +1,12 @@
class Object
- # Returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
- #
- # Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
- #
- # @return Object
- def itself
- self
+ unless respond_to?(:itself) # TODO: Remove this file when we drop support to Ruby < 2.2
+ # Returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
+ #
+ # Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
+ #
+ # @return Object
+ def itself
+ self
+ end
end
-end \ No newline at end of file
+end