From 23f902c05fa51a29a26e7afce1db2de475e1c8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 4 Aug 2014 16:23:22 -0300 Subject: 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 --- .../lib/active_support/core_ext/object/itself.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'activesupport') 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 -- cgit v1.2.3