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
- .attr_accessor(*vars) ⇒ Object
- .attributes ⇒ Object
-
.defaults ⇒ Hash
Specified default values for attribute readers.
- .inherited(child) ⇒ Object
-
.set_defaults(default_values) ⇒ Object
Sets default values for attribute readers, when an attribute reader returns ‘nil` the default values will be returned instead.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attributes ⇒ Object
-
#defaults ⇒ Hash
Specified default values for attribute readers.
- #hash ⇒ Object
-
#initialize ⇒ OptionGroup
constructor
A new instance of OptionGroup.
-
#merge(other) ⇒ OptionGroup
‘self`.
-
#to_h ⇒ Hash
Values for all attribute accessors which aren’t the defaults.
- #to_hash ⇒ Object
- #to_rpc_data ⇒ Object
-
#update(options) ⇒ OptionGroup
‘self`.
-
#validate ⇒ Hash
abstract
Hash of errors with the name of the invalid options as the keys.
Constructor Details
#initialize ⇒ OptionGroup
Returns a new instance of OptionGroup.
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
Returns Specified default values for attribute readers.
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 # Set the specified default values as overrides to the attribute # readers. 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
Returns Specified default values for attribute readers.
114 115 116 |
# File 'lib/arachni/option_group.rb', line 114 def defaults self.class.defaults end |
#hash ⇒ Object
91 92 93 |
# File 'lib/arachni/option_group.rb', line 91 def hash to_h.hash end |
#merge(other) ⇒ OptionGroup
Returns ‘self`.
109 110 111 |
# File 'lib/arachni/option_group.rb', line 109 def merge( other ) update( other.to_h ) end |
#to_h ⇒ Hash
Returns Values for all attribute accessors which aren’t the defaults.
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 |
#to_hash ⇒ Object
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 |
#update(options) ⇒ OptionGroup
Returns ‘self`.
100 101 102 103 |
# File 'lib/arachni/option_group.rb', line 100 def update( ) .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 |