aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/self.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2014-08-01 10:07:38 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2014-08-01 10:07:38 -0700
commit702ad710b57bef45b081ebf42e6fa70820fdd810 (patch)
treed6b1542c65b2e80d3e921d04e58d77b60d5b92d2 /activesupport/lib/active_support/core_ext/object/self.rb
parent20405e516b031db4d8230014d1dcf9601ed0a0f8 (diff)
downloadrails-702ad710b57bef45b081ebf42e6fa70820fdd810.tar.gz
rails-702ad710b57bef45b081ebf42e6fa70820fdd810.tar.bz2
rails-702ad710b57bef45b081ebf42e6fa70820fdd810.zip
Added Object#self which returns the object itself
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/self.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/self.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/self.rb b/activesupport/lib/active_support/core_ext/object/self.rb
new file mode 100644
index 0000000000..5c51bf56c9
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/object/self.rb
@@ -0,0 +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)
+ #
+ # @return Object
+ def self
+ self
+ end
+end \ No newline at end of file