Class: RightRails::JavaScriptGenerator
- Inherits:
-
Object
- Object
- RightRails::JavaScriptGenerator
- Includes:
- Methods
- Defined in:
- lib/right_rails/java_script_generator.rb
Overview
The right-rails scripts generator
Defined Under Namespace
Modules: Methods Classes: MethodCall, Util
Constant Summary collapse
- JS_CONSTANTS =
the top-level constants that the generator should respond to transparently
[:top, :RR]
Instance Method Summary collapse
-
#initialize(template, thread = nil) ⇒ JavaScriptGenerator
constructor
A new instance of JavaScriptGenerator.
-
#method_missing(name, *args) ⇒ Object
method calls catchup.
-
#to_s ⇒ Object
returns the result script.
Methods included from Methods
#<<, #[], #document, #find, #get, #insert, #insert_and_care, #redirect_to, #reload, #remove, #replace, #replace_and_care, #replace_form_for, #set, #show_form_for, #update_flash, #window
Constructor Details
#initialize(template, thread = nil) ⇒ JavaScriptGenerator
Returns a new instance of JavaScriptGenerator.
6 7 8 |
# File 'lib/right_rails/java_script_generator.rb', line 6 def initialize(template, thread=nil) @util = Util.new(template, thread) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
method calls catchup
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/right_rails/java_script_generator.rb', line 14 def method_missing(name, *args) cmd = if JS_CONSTANTS.include?(name) name elsif name.to_s[name.to_s.size-1, name.to_s.size] == '=' "#{name.to_s[0, name.to_s.size-1]}=#{@util.to_js_type(args.first)}" else "#{name}(#{@util.to_js_args(args)})" end @util.record(cmd) end |
Instance Method Details
#to_s ⇒ Object
returns the result script
27 28 29 |
# File 'lib/right_rails/java_script_generator.rb', line 27 def to_s @util.build_script end |