Class: JavascriptFunction
- Inherits:
-
JavascriptObject
- Object
- JavascriptObject
- JavascriptFunction
- Defined in:
- lib/vapir-firefox/javascript_object.rb
Overview
represents a javascript function
Instance Attribute Summary
Attributes inherited from JavascriptObject
#debug_name, #firefox_socket, #function_result, #ref
Instance Method Summary collapse
Methods inherited from JavascriptObject
#%, #*, #+, #-, #/, #<, #<=, #==, #>, #>=, #[], #[]=, always_define_methods, always_define_methods=, #assign, #assign_expr, #assign_or_call_or_val_or_object_by_suffix, #attr, #binary_operator, #call, #define_methods!, #implemented_interfaces, #initialize, #inspect, #instanceof, #invoke, #invoke?, #method_missing, #new, #object_respond_to?, #object_type, #pass, #pretty_print, #respond_to?, #store, #store_rand_object_key, #store_rand_temp, #sub, #to_array, #to_dom, #to_function, #to_hash, #to_js_array, #to_js_hash, #to_js_hash_safe, #to_ruby_array, #to_ruby_hash, #to_simple_enumerator, #triple_equals, #type, #val, #val_or_object, #val_str
Constructor Details
This class inherits a constructor from JavascriptObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JavascriptObject
Instance Method Details
#to_proc ⇒ Object
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/vapir-firefox/javascript_object.rb', line 730 def to_proc @the_proc ||= begin javascript_function = self the_proc = proc do |*args| javascript_function.call(*args) end # this makes it so you can recover the javascript_function from the proc # this method returns - js_func.to_proc.javascript_function returns js_func. # unfortunately it's not so useful because when you pass the proc as a block, # it's reinstantated without the metaclass or instance variable defined here. # still, may have some potential use, so leaving this here. = (class << the_proc; self; end) .send(:define_method, :javascript_function) do javascript_function end the_proc.instance_variable_set('@javascript_function', javascript_function) the_proc end end |