Permalink
Browse files

Rename Object#self to Object#itself to have parity with matz sanction…

…ed method name for Ruby 2.2
  • Loading branch information...
dhh committed Aug 1, 2014
1 parent 702ad71 commit 64d91122222c11ad3918cc8e2e3ebc4b0a03448a
@@ -1,6 +1,6 @@
-* Added Object#self which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
+* Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
- Event.public_send(state.presence_in?([ :trashed, :drafted ]) ? :self).order(:created_at)
+ Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
*DHH*
@@ -2,7 +2,7 @@
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/object/deep_dup'
-require 'active_support/core_ext/object/self'
+require 'active_support/core_ext/object/itself'
require 'active_support/core_ext/object/try'
require 'active_support/core_ext/object/inclusion'
@@ -1,10 +1,10 @@
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 ]) ? :self).order(:created_at)
+ # Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
#
# @return Object
- def self
+ def itself
self
end
end
@@ -4,6 +4,6 @@
class Object::SelfTest < ActiveSupport::TestCase

This comment has been minimized.

Show comment
Hide comment
@fw42

fw42 Aug 1, 2014

Contributor

and here? :)

@fw42

fw42 Aug 1, 2014

Contributor

and here? :)

test 'self returns self' do

This comment has been minimized.

Show comment
Hide comment
@fw42

fw42 Aug 1, 2014

Contributor

"s/self/itself/"?

@fw42

fw42 Aug 1, 2014

Contributor

"s/self/itself/"?

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Aug 1, 2014

Member

Already done.

@rafaelfranca

rafaelfranca Aug 1, 2014

Member

Already done.

object = 'fun'
- assert_equal object, object.self
+ assert_equal object, object.itself
end
end

0 comments on commit 64d9112

Please sign in to comment.