Class: CrossPost::Config::FifoSubConfig

Inherits:
SubConfig
  • Object
show all
Defined in:
lib/cross-post/config.rb

Instance Method Summary collapse

Methods inherited from SubConfig

#[], #each, #fetch

Constructor Details

#initialize(size = 100) ⇒ FifoSubConfig

Returns a new instance of FifoSubConfig.



60
61
62
63
64
# File 'lib/cross-post/config.rb', line 60

def initialize(size = 100)
	@size = size
	@keys = []
	super({})
end

Instance Method Details

#[]=(key, value) ⇒ Object



66
67
68
69
70
71
72
73
74
75
# File 'lib/cross-post/config.rb', line 66

def []=(key, value)
	@keys.delete key
	value = super key, value
	@keys << key
	while @keys.size > @size
		key = @keys.delete_at 0
		@config.delete key
	end
	value
end