Class: Ext::JavaScript::Var

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/java_script.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, bind) ⇒ Var

Returns a new instance of Var.



3
4
5
6
7
# File 'lib/ext/java_script.rb', line 3

def initialize(name, bind)
  @name = name
  @bind = bind
  @js   = "var %s = %s;" % [name, bind.to_s]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



9
10
11
# File 'lib/ext/java_script.rb', line 9

def method_missing(*args)
  @js << "%s.%s;" % [@name, @bind.__send__(*args)]
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/ext/java_script.rb', line 13

def to_s
  @js
end