Class: Arachni::OptionGroup
Overview
Direct Known Subclasses
Arachni::OptionGroups::Audit, Arachni::OptionGroups::BrowserCluster, Arachni::OptionGroups::Datastore, Arachni::OptionGroups::Dispatcher, Arachni::OptionGroups::HTTP, Arachni::OptionGroups::Input, Arachni::OptionGroups::Output, Arachni::OptionGroups::Paths, Arachni::OptionGroups::RPC, Arachni::OptionGroups::Scope, Arachni::OptionGroups::Session, Arachni::OptionGroups::Snapshot
Defined Under Namespace
Classes: Error
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
50
51
52
53
54
|
# File 'lib/arachni/option_group.rb', line 50
def initialize
defaults.each do |k, v|
send "#{k}=", v
end
end
|
Class Method Details
.attr_accessor(*vars) ⇒ Object
118
119
120
121
|
# File 'lib/arachni/option_group.rb', line 118
def self.attr_accessor( *vars )
attributes.concat( vars )
super( *vars )
end
|
.attributes ⇒ Object
123
124
125
|
# File 'lib/arachni/option_group.rb', line 123
def self.attributes
@attributes ||= []
end
|
.defaults ⇒ Hash
22
23
24
|
# File 'lib/arachni/option_group.rb', line 22
def defaults
@defaults ||= {}
end
|
.inherited(child) ⇒ Object
45
46
47
|
# File 'lib/arachni/option_group.rb', line 45
def inherited( child )
Options.register_group child
end
|
.set_defaults(default_values) ⇒ Object
Sets default values for attribute readers, when an attribute reader returns ‘nil` the default values will be returned instead.
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/arachni/option_group.rb', line 31
def set_defaults( default_values )
defaults.merge! default_values
defaults.each do |ivar, value|
define_method "#{ivar}=" do |v|
instance_variable_set( "@#{ivar}".to_sym, v.nil? ? value : v)
end
end
defaults
end
|
Instance Method Details
#==(other) ⇒ Object
87
88
89
|
# File 'lib/arachni/option_group.rb', line 87
def ==( other )
hash == other.hash
end
|
#attributes ⇒ Object
127
128
129
|
# File 'lib/arachni/option_group.rb', line 127
def attributes
self.class.attributes
end
|
#defaults ⇒ Hash
114
115
116
|
# File 'lib/arachni/option_group.rb', line 114
def defaults
self.class.defaults
end
|
91
92
93
|
# File 'lib/arachni/option_group.rb', line 91
def hash
to_h.hash
end
|
109
110
111
|
# File 'lib/arachni/option_group.rb', line 109
def merge( other )
update( other.to_h )
end
|
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/arachni/option_group.rb', line 62
def to_h
h = {}
instance_variables.each do |ivar|
method = normalize_ivar( ivar )
sym = method.to_sym
value = instance_variable_get( ivar )
next if !respond_to?( "#{method}=" )
h[sym] = value
end
h
end
|
75
76
77
|
# File 'lib/arachni/option_group.rb', line 75
def to_hash
to_h
end
|
#to_rpc_data ⇒ Object
56
57
58
|
# File 'lib/arachni/option_group.rb', line 56
def to_rpc_data
to_h.my_stringify_keys(false)
end
|
100
101
102
103
|
# File 'lib/arachni/option_group.rb', line 100
def update( options )
options.to_hash.each { |k, v| send( "#{k}=", v ) }
self
end
|
#validate ⇒ Hash
Returns Hash of errors with the name of the invalid options as the keys.
83
84
85
|
# File 'lib/arachni/option_group.rb', line 83
def validate
{}
end
|