Class: Rack::BlacklistCookies::Configuration
- Inherits:
-
Object
- Object
- Rack::BlacklistCookies::Configuration
- Defined in:
- lib/rack/blacklist_cookies/configuration.rb
Overview
Configuration defaults to an empty hash if it has not been set.
Instance Attribute Summary collapse
-
#request_blacklist ⇒ Object
Returns the value of attribute request_blacklist.
-
#response_blacklist ⇒ Object
Returns the value of attribute response_blacklist.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset ⇒ Object
-
#validate ⇒ Object
rubocop:disable MethodLength.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 |
# File 'lib/rack/blacklist_cookies/configuration.rb', line 8 def initialize @request_blacklist = {} @response_blacklist = {} end |
Instance Attribute Details
#request_blacklist ⇒ Object
Returns the value of attribute request_blacklist.
6 7 8 |
# File 'lib/rack/blacklist_cookies/configuration.rb', line 6 def request_blacklist @request_blacklist end |
#response_blacklist ⇒ Object
Returns the value of attribute response_blacklist.
6 7 8 |
# File 'lib/rack/blacklist_cookies/configuration.rb', line 6 def response_blacklist @response_blacklist end |
Instance Method Details
#reset ⇒ Object
13 14 15 16 |
# File 'lib/rack/blacklist_cookies/configuration.rb', line 13 def reset @request_blacklist = {} @response_blacklist = {} end |
#validate ⇒ Object
rubocop:disable MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rack/blacklist_cookies/configuration.rb', line 19 def validate [@request_blacklist, @response_blacklist].each do |blacklist| raise ConfigurationError, "Blacklist is not a hash" unless blacklist.is_a?(Hash) blacklist.each do |route, | raise ConfigurationError, "Blacklist key is not a string" unless route.is_a?(String) raise ConfigurationError, "Blacklist value is not an array" unless .is_a?(Array) raise ConfigurationError, "Blacklist key is not a URL path" unless route.start_with?("/") .each do || raise ConfigurationError, "Blacklist cookie is not a valid name string" unless .is_a?(String) end end end end |