Class: PostHog::Utils::SizeLimitedHash

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

Instance Method Summary collapse

Constructor Details

#initialize(max_length) ⇒ SizeLimitedHash

Returns a new instance of SizeLimitedHash.



116
117
118
119
# File 'lib/posthog/utils.rb', line 116

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

Instance Method Details

#[]=(key, value) ⇒ Object



121
122
123
124
# File 'lib/posthog/utils.rb', line 121

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