Class: WebShield::Shield
- Inherits:
-
Object
- Object
- WebShield::Shield
- Defined in:
- lib/web_shield/shield.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path_matcher ⇒ Object
readonly
Returns the value of attribute path_matcher.
-
#shield_path ⇒ Object
readonly
Returns the value of attribute shield_path.
Instance Method Summary collapse
- #dictatorial? ⇒ Boolean
-
#filter(request) ⇒ Object
Returns: :pass, :block, [:response, rack_response], nil.
-
#initialize(id, shield_path, options, config) ⇒ Shield
constructor
A new instance of Shield.
- #shield_name ⇒ Object
- #write_log(severity, msg) ⇒ Object
Constructor Details
#initialize(id, shield_path, options, config) ⇒ Shield
Returns a new instance of Shield.
7 8 9 10 11 12 13 |
# File 'lib/web_shield/shield.rb', line 7 def initialize(id, shield_path, , config) @id = id @shield_path = shield_path @path_matcher = build_path_matcher(shield_path) = hash_to_symbol_keys() @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/web_shield/shield.rb', line 5 def config @config end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/web_shield/shield.rb', line 5 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/web_shield/shield.rb', line 5 def end |
#path_matcher ⇒ Object (readonly)
Returns the value of attribute path_matcher.
5 6 7 |
# File 'lib/web_shield/shield.rb', line 5 def path_matcher @path_matcher end |
#shield_path ⇒ Object (readonly)
Returns the value of attribute shield_path.
5 6 7 |
# File 'lib/web_shield/shield.rb', line 5 def shield_path @shield_path end |
Instance Method Details
#dictatorial? ⇒ Boolean
20 21 22 |
# File 'lib/web_shield/shield.rb', line 20 def dictatorial? [:dictatorial] end |
#filter(request) ⇒ Object
Returns: :pass, :block, [:response, rack_response], nil
16 17 18 |
# File 'lib/web_shield/shield.rb', line 16 def filter(request) raise Error, "implement me" end |
#shield_name ⇒ Object
33 34 35 |
# File 'lib/web_shield/shield.rb', line 33 def shield_name self.class.name.split('::', 2).last + "\##{id}" end |
#write_log(severity, msg) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/web_shield/shield.rb', line 24 def write_log(severity, msg) case svrt = severity.to_sym when :debug, :info, :warn, :error config.logger.send(svrt, "#{shield_name} #{msg}") else raise "Invalid log severity '#{svrt}'" end end |