Module: Arachni::Element::Capabilities::Inputtable
- Included in:
- Auditable
- Defined in:
- lib/arachni/element/capabilities/inputtable.rb
Overview
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#default_inputs ⇒ Hash
readonly
Frozen version of #inputs, has all the original names and values.
-
#inputs ⇒ Hash
Frozen effective inputs.
Instance Method Summary collapse
-
#[](name) ⇒ String
Shorthand #inputs reader.
-
#[]=(name, value) ⇒ Object
Shorthand #inputs writer.
-
#changes ⇒ Hash
Returns changes make to the #inputs‘s inputs.
- #dup ⇒ Object
-
#has_inputs?(*args) ⇒ Bool
Checks whether or not the given inputs match the inputs ones.
-
#inputtable_id ⇒ String
Uniquely identifies the #inputs.
-
#reset ⇒ Object
Resets the inputs to their original format/values.
- #to_h ⇒ Object
-
#try_input(&block) ⇒ Bool
Performs an input operation and silently handles Error::InvalidData.
-
#update(hash) ⇒ Auditable
‘self`.
-
#valid_input_data?(data) ⇒ Bool
abstract
‘true` if the data can be carried by the element’s inputs, ‘false` otherwise.
-
#valid_input_name?(name) ⇒ Bool
abstract
‘true` if the name can be carried by the element’s inputs, ‘false` otherwise.
-
#valid_input_name_data?(name) ⇒ Bool
‘true` if `name` is both a #valid_input_name? and contains #valid_input_data?.
-
#valid_input_value?(value) ⇒ Bool
abstract
‘true` if the value can be carried by the element’s inputs, ‘false` otherwise.
-
#valid_input_value_data?(value) ⇒ Bool
‘true` if `value` is both a #valid_input_value? and contains #valid_input_data?.
Instance Attribute Details
Instance Method Details
#[](name) ⇒ String
Shorthand #inputs reader.
113 114 115 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 113 def []( name ) @inputs[name.to_s] end |
#[]=(name, value) ⇒ Object
Shorthand #inputs writer.
126 127 128 129 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 126 def []=( name, value ) update( name.to_s => value.to_s ) self[name] end |
#changes ⇒ Hash
Returns changes make to the #inputs‘s inputs.
91 92 93 94 95 96 97 98 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 91 def changes (@default_inputs.keys | @inputs.keys).inject( {} ) do |h, k| if @default_inputs[k] != @inputs[k] h[k] = @inputs[k] end h end end |
#dup ⇒ Object
217 218 219 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 217 def dup copy_inputtable( super ) end |
#has_inputs?(*args) ⇒ Bool
Checks whether or not the given inputs match the inputs ones.
79 80 81 82 83 84 85 86 87 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 79 def has_inputs?( *args ) if (h = args.first).is_a?( Hash ) h.each { |k, v| return false if self[k] != v } true else keys = args.flatten.compact.map { |a| [a].map(&:to_s) }.flatten (@inputs.keys & keys).size == keys.size end end |
#inputtable_id ⇒ String
Returns Uniquely identifies the #inputs.
223 224 225 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 223 def inputtable_id inputs.sort_by { |k,_| k }.to_s end |
#reset ⇒ Object
Resets the inputs to their original format/values.
101 102 103 104 105 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 101 def reset super if defined?( super ) self.inputs = @default_inputs.dup self end |
#to_h ⇒ Object
227 228 229 230 231 232 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 227 def to_h (defined?( super ) ? super : {}).merge( inputs: inputs, default_inputs: default_inputs ) end |
#try_input(&block) ⇒ Bool
Performs an input operation and silently handles Arachni::Element::Capabilities::Inputtable::Error::InvalidData.
206 207 208 209 210 211 212 213 214 215 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 206 def try_input( &block ) block.call true rescue Error::InvalidData => e return false if !respond_to?( :print_debug_level_1 ) print_debug_level_1 e.to_s e.backtrace.each { |l| print_debug_level_1 l } false end |
#update(hash) ⇒ Auditable
Returns ‘self`.
138 139 140 141 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 138 def update( hash ) self.inputs = @inputs.merge( hash ) self end |
#valid_input_data?(data) ⇒ Bool
Returns ‘true` if the data can be carried by the element’s inputs, ‘false` otherwise.
195 196 197 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 195 def valid_input_data?( data ) true end |
#valid_input_name?(name) ⇒ Bool
Returns ‘true` if the name can be carried by the element’s inputs, ‘false` otherwise.
151 152 153 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 151 def valid_input_name?( name ) true end |
#valid_input_name_data?(name) ⇒ Bool
Returns ‘true` if `name` is both a #valid_input_name? and contains #valid_input_data?.
161 162 163 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 161 def valid_input_name_data?( name ) valid_input_name?( name ) && valid_input_data?( name ) end |
#valid_input_value?(value) ⇒ Bool
Returns ‘true` if the value can be carried by the element’s inputs, ‘false` otherwise.
173 174 175 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 173 def valid_input_value?( value ) true end |
#valid_input_value_data?(value) ⇒ Bool
Returns ‘true` if `value` is both a #valid_input_value? and contains #valid_input_data?.
183 184 185 |
# File 'lib/arachni/element/capabilities/inputtable.rb', line 183 def valid_input_value_data?( value ) valid_input_value?( value ) && valid_input_data?( value ) end |