aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-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