aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/itself.rb
blob: d71cea66744d8f580005c07c66ac48fc92f367e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Object
  # TODO: Remove this file when we drop support for Ruby < 2.2
  unless respond_to?(:itself)
    # Returns the object itself.
    #
    # Useful for chaining methods, such as Active Record scopes:
    #
    #   Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
    #
    # @return Object
    def itself
      self
    end
  end
end