Class: Buttons::Javascript::JsArg
- Defined in:
- lib/buttons/javascript/js_arg.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from JsVar
Instance Method Summary collapse
- #default ⇒ Object
-
#initialize(var) ⇒ JsArg
constructor
A new instance of JsArg.
- #method_missing(*args, &block) ⇒ Object
- #to_default(index) ⇒ Object
Methods inherited from JsVar
Constructor Details
#initialize(var) ⇒ JsArg
Returns a new instance of JsArg.
6 7 8 9 |
# File 'lib/buttons/javascript/js_arg.rb', line 6 def initialize(var) @var = var super(@var.name) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
11 12 13 |
# File 'lib/buttons/javascript/js_arg.rb', line 11 def method_missing(*args, &block) @var.send(*args, &block) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/buttons/javascript/js_arg.rb', line 4 def name @name end |
Instance Method Details
#default ⇒ Object
15 16 17 |
# File 'lib/buttons/javascript/js_arg.rb', line 15 def default @var.default.to_json end |
#to_default(index) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/buttons/javascript/js_arg.rb', line 19 def to_default(index) if optional? %Q[ if (#{name} === undefined) { #{name} = #{default}; } ] end end |