HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/ruby/vendor_ruby/jbuilder/key_formatter.rb
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