aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/itself.rb
blob: adedc20169521229d36ba5de0e077b0449381f08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class Object
  unless respond_to?(:itself) # TODO: Remove this file when we drop support for 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