module Stockboy::StringPool
Holds frozen strings for shared lookup between different object instances
@visibility private
Public Instance Methods
string_pool(name)
click to toggle source
Look up duplicate strings and return the shared frozen string
@return [String]
# File lib/stockboy/string_pool.rb, line 25 def string_pool(name) if i = @string_pool.index(name) @string_pool[i] else @string_pool << name.freeze name end end
with_string_pool() { || ... }
click to toggle source
Pass a block to yield a new string pool context around a group of actions that should share the same string key instances
@yield
# File lib/stockboy/string_pool.rb, line 14 def with_string_pool @string_pool = [] result = yield @string_pool = [] result end