enumerate(enumerable, options = {}, &block)
private
Options
* variable - name of the variable to set the result of the enumeration to
* method_args - array of the javascript enumeration method args that occur before the function
* yield_args - array of the javascript yield args
* return - true if the enumeration should return the last statement
# File actionpack/lib/action_view/helpers/prototype_helper.rb, line 815
def enumerate(enumerable, options = {}, &block)
options[:method_args] ||= []
options[:yield_args] ||= []
yield_args = options[:yield_args] * ', '
method_args = arguments_for_call options[:method_args] # foo, bar, function
method_args << ', ' unless method_args.blank?
add_variable_assignment!(options[:variable]) if options[:variable]
append_enumerable_function!("#{enumerable.to_s.camelize(:lower)}(#{method_args}function(#{yield_args}) {")
# only yield as many params as were passed in the block
yield(*options[:yield_args].collect { |p| JavaScriptVariableProxy.new(@generator, p) }[0..block.arity-1])
add_return_statement! if options[:return]
@generator << '});'
end