Class: JavaScript::Prototype
- Inherits:
-
Object
- Object
- BlankObject
- Object
- JavaScript::Prototype
- Defined in:
- lib/javascript.rb
Instance Method Summary collapse
-
#initialize(klass) ⇒ Prototype
constructor
A new instance of Prototype.
Methods inherited from Object
#!=, #==, #===, #[], #[]=, #__defined__?, #__hash__, #__proto__
Constructor Details
#initialize(klass) ⇒ Prototype
Returns a new instance of Prototype.
291 292 293 294 |
# File 'lib/javascript.rb', line 291 def initialize(klass) super(nil) @klass = klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
297 298 299 300 301 302 303 304 |
# File 'lib/javascript.rb', line 297 def method_missing(name, *args, &block) meth = @klass.instance_method(name) args = meth.parameters.map { |_, name| name && Identifier.new(name) }.compact body = ->(*args) { meth.bind(this).call(*args) } Function.new(name, args, body) rescue NameError super end |