Module: Arachni::Element::Capabilities::Refreshable
Overview
Instance Method Summary collapse
-
#refresh(http_opts = {}, &block) ⇒ Form
Refreshes the form's inputs and re-applies user updates.
-
#refresh_id ⇒ String
abstract
Unique string identifying this element while disregarding any applied runtime modifications (usually to its Inputtable#inputs).
Instance Method Details
#refresh(http_opts = {}, &block) ⇒ Form
Refreshes the form's inputs and re-applies user updates.
The way it works is by requesting the Base#url, parsing the response and updating the form with the fresh form's inputs.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/arachni/element/capabilities/refreshable.rb', line 26 def refresh( http_opts = {}, &block ) updated = nil http.get( url.to_s, http_opts.merge( mode: block_given? ? :async : :sync ) ) do |res| # Find the original version of self in the response. f = self.class.from_response( res ). find { |f| f.refresh_id == refresh_id } if !f block.call if block_given? next end # get user updates updates = changes # update the form's inputs with the fresh ones and re-apply the user changes updated = update( f.inputs ).update( updates ) block.call( updated ) if block_given? end updated end |
#refresh_id ⇒ String
This method is abstract.
Returns Unique string identifying this element while disregarding any applied runtime modifications (usually to its Inputtable#inputs).
Basically, a modified element and a fresh element should both return the same value while uniquely identifying the pair.
56 57 58 |
# File 'lib/arachni/element/capabilities/refreshable.rb', line 56 def refresh_id "#{action}:#{type}:#{default_inputs.keys.sort}" end |