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.



134
135
136
137
# File 'lib/posthog/utils.rb', line 134

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

Instance Method Details

#[]=(key, value) ⇒ Object



139
140
141
142
# File 'lib/posthog/utils.rb', line 139

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