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.



99
100
101
102
# File 'lib/posthog/utils.rb', line 99

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

Instance Method Details

#[]=(key, value) ⇒ Object



104
105
106
107
108
109
# File 'lib/posthog/utils.rb', line 104

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