Skip to content

Commit 64d9112

Browse files
author
David Heinemeier Hansson
committed
Rename Object#self to Object#itself to have parity with matz sanctioned method name for Ruby 2.2
1 parent 702ad71 commit 64d9112

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

activesupport/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
* Added Object#self which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
1+
* Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
22

3-
Event.public_send(state.presence_in?([ :trashed, :drafted ]) ? :self).order(:created_at)
3+
Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
44

55
*DHH*
66

activesupport/lib/active_support/core_ext/object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'active_support/core_ext/object/blank'
33
require 'active_support/core_ext/object/duplicable'
44
require 'active_support/core_ext/object/deep_dup'
5-
require 'active_support/core_ext/object/self'
5+
require 'active_support/core_ext/object/itself'
66
require 'active_support/core_ext/object/try'
77
require 'active_support/core_ext/object/inclusion'
88

activesupport/lib/active_support/core_ext/object/self.rb renamed to activesupport/lib/active_support/core_ext/object/itself.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class Object
22
# Returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
33
#
4-
# Event.public_send(state.presence_in?([ :trashed, :drafted ]) ? :self).order(:created_at)
4+
# Event.public_send(state.presence_in?([ :trashed, :drafted ]) || :itself).order(:created_at)
55
#
66
# @return Object
7-
def self
7+
def itself
88
self
99
end
1010
end

activesupport/test/core_ext/object/self_test.rb renamed to activesupport/test/core_ext/object/itself_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
class Object::SelfTest < ActiveSupport::TestCase
55
test 'self returns self' do
66
object = 'fun'
7-
assert_equal object, object.self
7+
assert_equal object, object.itself
88
end
99
end

0 commit comments

Comments
 (0)