Class: ActionView::Helpers::JavaScriptCollectionProxy
- Inherits:
-
JavaScriptProxy
show all
- Defined in:
- actionpack/lib/action_view/helpers/prototype_helper.rb
Overview
Constant Summary
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
-
- (Object) each_slice(variable, number, &block)
-
- (Object) grep(variable, pattern, &block)
-
- (Object) in_groups_of(variable, number, fill_with = nil)
-
- (JavaScriptCollectionProxy) initialize(generator, pattern)
constructor
A new instance of JavaScriptCollectionProxy.
-
- (Object) inject(variable, memo, &block)
-
- (Object) pluck(variable, property)
-
- (Object) zip(variable, *arguments, &block)
#is_a?
#raise
Constructor Details
A new instance of JavaScriptCollectionProxy
754
755
756
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 754
def initialize(generator, pattern)
super(generator, @pattern = pattern)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *arguments, &block)
801
802
803
804
805
806
807
808
809
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 801
def method_missing(method, *arguments, &block)
if ENUMERABLE_METHODS.include?(method)
returnable = ENUMERABLE_METHODS_WITH_RETURN.include?(method)
variable = arguments.first if returnable
enumerate(method, {:variable => (arguments.first if returnable), :return => returnable, :yield_args => %w(value index)}, &block)
else
super
end
end
|
Instance Attribute Details
- (Object) generator
Returns the value of attribute generator
751
752
753
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 751
def generator
@generator
end
|
Instance Method Details
- (Object) each_slice(variable, number, &block)
758
759
760
761
762
763
764
765
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 758
def each_slice(variable, number, &block)
if block
enumerate :eachSlice, :variable => variable, :method_args => [number], :yield_args => %w(value index), :return => true, &block
else
add_variable_assignment!(variable)
append_enumerable_function!("eachSlice(#{::ActiveSupport::JSON.encode(number)});")
end
end
|
- (Object) grep(variable, pattern, &block)
767
768
769
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 767
def grep(variable, pattern, &block)
enumerate :grep, :variable => variable, :return => true, :method_args => [::ActiveSupport::JSON::Variable.new(pattern.inspect)], :yield_args => %w(value index), &block
end
|
- (Object) in_groups_of(variable, number, fill_with = nil)
771
772
773
774
775
776
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 771
def in_groups_of(variable, number, fill_with = nil)
arguments = [number]
arguments << fill_with unless fill_with.nil?
add_variable_assignment!(variable)
append_enumerable_function!("inGroupsOf(#{arguments_for_call arguments});")
end
|
- (Object) inject(variable, memo, &block)
778
779
780
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 778
def inject(variable, memo, &block)
enumerate :inject, :variable => variable, :method_args => [memo], :yield_args => %w(memo value index), :return => true, &block
end
|
- (Object) pluck(variable, property)
782
783
784
785
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 782
def pluck(variable, property)
add_variable_assignment!(variable)
append_enumerable_function!("pluck(#{::ActiveSupport::JSON.encode(property)});")
end
|
- (Object) zip(variable, *arguments, &block)
787
788
789
790
791
792
793
794
795
796
797
798
|
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 787
def zip(variable, *arguments, &block)
add_variable_assignment!(variable)
append_enumerable_function!("zip(#{arguments_for_call arguments}")
if block
function_chain[-1] += ", function(array) {"
yield ::ActiveSupport::JSON::Variable.new('array')
add_return_statement!
@generator << '});'
else
function_chain[-1] += ');'
end
end
|