Class: PostHog::Utils::SizeLimitedHash

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

Instance Method Summary collapse

Constructor Details

#initialize(max_length, *args, &block) ⇒ SizeLimitedHash

Returns a new instance of SizeLimitedHash.



119
120
121
122
# File 'lib/posthog/utils.rb', line 119

def initialize(max_length, *args, &block)
  super(*args, &block)
  @max_length = max_length
end

Instance Method Details

#[]=(key, value) ⇒ Object



124
125
126
127
128
129
# File 'lib/posthog/utils.rb', line 124

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