Class: Injector
- Inherits:
-
Object
show all
- Defined in:
- lib/js.rb
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(name) ⇒ Injector
Returns a new instance of Injector.
26
27
28
|
# File 'lib/js.rb', line 26
def initialize(name)
@name, @methods = name, []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
34
35
36
37
|
# File 'lib/js.rb', line 34
def method_missing(name, *args, &block)
@methods << name.to_s
self
end
|
Instance Method Details
#[](key) ⇒ Object
30
31
32
|
# File 'lib/js.rb', line 30
def [](key)
method_missing(key)
end
|
#__name__ ⇒ Object
43
44
45
|
# File 'lib/js.rb', line 43
def __name__
@name
end
|
#__reset__! ⇒ Object
39
40
41
|
# File 'lib/js.rb', line 39
def __reset__!
@methods.clear
end
|
#to_s ⇒ Object
47
48
49
50
51
|
# File 'lib/js.rb', line 47
def to_s
js = "{{#{@name}.#{@methods.join('.')}}}"
__reset__!
js
end
|
#to_str ⇒ Object
53
54
55
|
# File 'lib/js.rb', line 53
def to_str
to_s
end
|