class Jbuilder::KeyFormatter - jbuilder-1.5.3 Documentation

# class Jbuilder::KeyFormatter

### Public Class Methods

new(*args) click to toggle source

    # File lib/jbuilder.rb, line 24
    def initialize(*args)
      @format = ::ActiveSupport::OrderedHash.new
      @cache = {}

      options = args.extract_options!
      args.each do |name|
        @format[name] = []
      end
      options.each do |name, paramaters|
        @format[name] = paramaters
      end
    end

### Public Instance Methods

format(key) click to toggle source

    # File lib/jbuilder.rb, line 41
    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

initialize_copy(original) click to toggle source

    # File lib/jbuilder.rb, line 37
    def initialize_copy(original)
      @cache = {}
    end