Class: Rails5XHRUpdate::XHRToRails5
- Inherits:
-
Parser::TreeRewriter
- Object
- Parser::TreeRewriter
- Rails5XHRUpdate::XHRToRails5
- Defined in:
- lib/rails5_xhr_update/xhr_to_rails5.rb
Overview
Convert uses of the xhr method to use the rails 5 syntax.
For example prior to rails 5 one might write:
xhr :get, images_path, limit: 10, sort: 'new'
This class will convert that into:
get images_path, params: { limit: 10, sort: 'new' }, xhr: true
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/rails5_xhr_update/xhr_to_rails5.rb', line 20 def on_send(node) return if node.children[1] != :xhr arguments = extract_and_validate_arguments(node) children = initial_children(node) + add_xhr_node(*arguments) replace(node.loc.expression, Rails5XHRUpdate.ast_to_string( node.updated(nil, children) )) end |