Class: WebShield::Shield

Inherits:
Object
  • Object
show all
Defined in:
lib/web_shield/shield.rb

Direct Known Subclasses

ThrottleShield

Constant Summary collapse

OPTION_KEYS =
[:period, :limit, :method, :path_sensitive, :dictatorial]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, shield_path, options, config) ⇒ Shield

Params:

path:
options:
  period: required
  limit: required
  method: optional
  path_sensitive: optional, defualt false


15
16
17
18
19
20
21
# File 'lib/web_shield/shield.rb', line 15

def initialize(id, shield_path, options, config)
  @id = id
  @shield_path = shield_path
  @path_matcher = build_path_matcher(shield_path)
  @options = hash_to_symbol_keys(options)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



5
6
7
# File 'lib/web_shield/shield.rb', line 5

def config
  @config
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/web_shield/shield.rb', line 5

def id
  @id
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/web_shield/shield.rb', line 5

def options
  @options
end

#path_matcherObject (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_pathObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/web_shield/shield.rb', line 28

def dictatorial?
  @options[:dictatorial]
end

#filter(request) ⇒ Object

Returns: :pass, :block, [:response, rack_response], nil

Raises:



24
25
26
# File 'lib/web_shield/shield.rb', line 24

def filter(request)
  raise Error, "implement me"
end