class Hash

def as_json(options = nil) # :nodoc:

Experimental RBS support (using type sampling data from the type_fusion project).

def as_json: (?Hash? options) -> untyped

This signature was generated using 4 samples from 1 application.

:nodoc:
def as_json(options = nil) # :nodoc:
  # create a subset of the hash by applying :only or :except
  subset = if options
    if attrs = options[:only]
      slice(*Array(attrs))
    elsif attrs = options[:except]
      except(*Array(attrs))
    else
      self
    end
  else
    self
  end
  result = {}
  subset.each do |k, v|
    result[k.to_s] = options ? v.as_json(options.dup) : v.as_json
  end
  result
end