class JSONAPI::FormatterWrapperCache
Warning: Not thread-safe. Wrap in ThreadLocalVar as needed.
Attributes
formatter_klass[R]
Public Class Methods
new(formatter_klass)
click to toggle source
# File lib/jsonapi/formatter.rb, line 70 def initialize(formatter_klass) @formatter_klass = formatter_klass @format_cache = NaiveCache.new{|arg| formatter_klass.format(arg) } @unformat_cache = NaiveCache.new{|arg| formatter_klass.unformat(arg) } end
Public Instance Methods
cached()
click to toggle source
# File lib/jsonapi/formatter.rb, line 84 def cached self end
format(arg)
click to toggle source
# File lib/jsonapi/formatter.rb, line 76 def format(arg) @format_cache.get(arg) end
uncached()
click to toggle source
# File lib/jsonapi/formatter.rb, line 88 def uncached return @formatter_klass end
unformat(arg)
click to toggle source
# File lib/jsonapi/formatter.rb, line 80 def unformat(arg) @unformat_cache.get(arg) end