Class: Buttons::Javascript::JsFunction
- Defined in:
- lib/buttons/javascript/js_function.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from JsVar
Instance Method Summary collapse
-
#initialize(name, http_method, url, args) ⇒ JsFunction
constructor
A new instance of JsFunction.
- #to_js(namespace = 'this') ⇒ Object
Methods inherited from JsVar
Constructor Details
#initialize(name, http_method, url, args) ⇒ JsFunction
Returns a new instance of JsFunction.
6 7 8 9 10 11 12 |
# File 'lib/buttons/javascript/js_function.rb', line 6 def initialize(name, http_method, url, args) super(name) @http_method = http_method @url = url @args = args.map { |arg| JsArg.new(arg) } end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
4 5 6 |
# File 'lib/buttons/javascript/js_function.rb', line 4 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/buttons/javascript/js_function.rb', line 4 def name @name end |
Instance Method Details
#to_js(namespace = 'this') ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/buttons/javascript/js_function.rb', line 14 def to_js(namespace = 'this') %Q[ #{namespace}.#{name} = function (#{args_to_param_list}, _ajaxOptions) { #{args_to_defaults} #{assign_args_to_js_object} #{ajax_call} }; ].strip_whitespace end |