Class: PostHog::Utils::SizeLimitedHash Private

Inherits:
Hash
  • Object
show all
Defined in:
lib/posthog/utils.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Hash that clears itself when it reaches a maximum length.

Instance Method Summary collapse

Constructor Details

#initialize(max_length) ⇒ SizeLimitedHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SizeLimitedHash.

Parameters:

  • max_length (Integer)


156
157
158
159
# File 'lib/posthog/utils.rb', line 156

def initialize(max_length, ...)
  super(...)
  @max_length = max_length
end

Instance Method Details

#[]=(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • key (Object)
  • value (Object)

Returns:

  • (Object)


164
165
166
167
# File 'lib/posthog/utils.rb', line 164

def []=(key, value)
  clear if length >= @max_length
  super
end