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.



114
115
116
117
# File 'lib/posthog/utils.rb', line 114

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

Instance Method Details

#[]=(key, value) ⇒ Object



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

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