File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed
lib/active_support/core_ext Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Added Object#self which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
2
+
3
+ Event.public_send(state.presence_in?([ :trashed, :drafted ]) ? :self).order(:created_at)
4
+
5
+ * DHH*
6
+
1
7
* ` Object#with_options ` executes block in merging option context when
2
8
explicit receiver in not passed.
3
9
Original file line number Diff line number Diff line change 2
2
require 'active_support/core_ext/object/blank'
3
3
require 'active_support/core_ext/object/duplicable'
4
4
require 'active_support/core_ext/object/deep_dup'
5
+ require 'active_support/core_ext/object/self'
5
6
require 'active_support/core_ext/object/try'
6
7
require 'active_support/core_ext/object/inclusion'
7
8
Original file line number Diff line number Diff line change
1
+ class Object
2
+ # Returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
3
+ #
4
+ # Event.public_send(state.presence_in?([ :trashed, :drafted ]) ? :self).order(:created_at)
5
+ #
6
+ # @return Object
7
+ def self
8
+ self
9
+ end
10
+ end
Original file line number Diff line number Diff line change
1
+ require 'abstract_unit'
2
+ require 'active_support/core_ext/object'
3
+
4
+ class Object ::SelfTest < ActiveSupport ::TestCase
5
+ test 'self returns self' do
6
+ object = 'fun'
7
+ assert_equal object , object . self
8
+ end
9
+ end
You can’t perform that action at this time.
0 commit comments