Sha256: 16efbebfb6539640bd907e22e63a7a055b7b04066896190f703d297c92e3b194
Contents?: true
Size: 685 Bytes
Versions: 22
Compression:
Stored size: 685 Bytes
Contents
require 'jbuilder/jbuilder' require 'active_support/core_ext/array' class Jbuilder class KeyFormatter def initialize(*args) @format = {} @cache = {} options = args.extract_options! args.each do |name| @format[name] = [] end options.each do |name, parameters| @format[name] = parameters end end def initialize_copy(original) @cache = {} end def format(key) @cache[key] ||= @format.inject(key.to_s) do |result, args| func, args = args if ::Proc === func func.call result, *args else result.send func, *args end end end end end
Version data entries
22 entries across 22 versions & 3 rubygems