Module: Arachni::Element::JSON::Capabilities::Inputtable

Includes:
Capabilities::Inputtable
Defined in:
lib/arachni/element/json/capabilities/inputtable.rb

Overview

Extends Capabilities::Inputtable with Arachni::Element::JSON-specific functionality.

Author:

Constant Summary

Constants included from Capabilities::Inputtable

Capabilities::Inputtable::INPUTTABLE_CACHE

Instance Attribute Summary

Attributes included from Capabilities::Inputtable

#default_inputs, #inputs, #raw_inputs

Instance Method Summary collapse

Methods included from Capabilities::Inputtable

#changes, #dup, #has_inputs?, #initialize, inputtable_id, #inputtable_id, #raw_input?, #reset, #to_h, #try_input, #updated?, #valid_input_data?, #valid_input_name?, #valid_input_name_data?, #valid_input_value?, #valid_input_value_data?

Instance Method Details

#[](name) ⇒ Object

Overrides #[] to allow for non-string data of variable depth.

Parameters:

  • name (Array<String>, String)

    Name of the input whose value to retrieve.

    If the name is an Array, it will be treated as a path to the location of the input.

Returns:

See Also:


49
50
51
52
# File 'lib/arachni/element/json/capabilities/inputtable.rb', line 49

def []( name )
    key, data = find( name )
    data[key]
end

#[]=(name, value) ⇒ Object

Overrides #[]= to allow for non-string data of variable depth.

Parameters:

  • name (Array<String>, String)

    Name of the input whose value to set.

    If the name is an Array, it will be treated as a path to the location of the input.

  • value (Object)

    Value to set.

Returns:

See Also:


69
70
71
72
73
74
75
76
77
78
# File 'lib/arachni/element/json/capabilities/inputtable.rb', line 69

def []=( name, value )
    @inputs = @inputs.dup
    key, data = find( name )

    fail_if_invalid( [key].flatten.last, value )

    data[key] = value
    @inputs.freeze
    value
end

#inputs=(h) ⇒ Object

Overrides Capabilities::Inputtable#inputs= to allow for non-string data of variable depth.

Parameters:

  • hash (Hash)

    Input data.

Raises:

See Also:


28
29
30
31
32
33
34
35
# File 'lib/arachni/element/json/capabilities/inputtable.rb', line 28

def inputs=( h )
    h = h.my_stringify_keys

    @inputs = h
    update h
    @inputs.freeze
    self.inputs
end

#update(hash) ⇒ Auditable

Overrides #update to allow for non-string data of variable depth.

Parameters:

Returns:

  • (Auditable)

    self

Raises:

See Also:


88
89
90
91
92
93
# File 'lib/arachni/element/json/capabilities/inputtable.rb', line 88

def update( hash )
    traverse_data hash do |path, value|
        self[path] = value
    end
    self
end