Class: Datadome::Inquirer
- Inherits:
-
Object
- Object
- Datadome::Inquirer
- Defined in:
- lib/datadome/inquirer.rb
Instance Method Summary collapse
- #build_response ⇒ Object
- #enriching ⇒ Object
- #ignore? ⇒ Boolean
-
#initialize(env, exclude_matchers: nil, include_matchers: nil) ⇒ Inquirer
constructor
A new instance of Inquirer.
- #inquire ⇒ Object
- #intercept? ⇒ Boolean
Constructor Details
#initialize(env, exclude_matchers: nil, include_matchers: nil) ⇒ Inquirer
Returns a new instance of Inquirer.
8 9 10 11 12 13 |
# File 'lib/datadome/inquirer.rb', line 8 def initialize(env, exclude_matchers: nil, include_matchers: nil) @env = env @exclude_matchers = exclude_matchers || Datadome.configuration.exclude_matchers @include_matchers = include_matchers || Datadome.configuration.include_matchers end |
Instance Method Details
#build_response ⇒ Object
15 16 17 |
# File 'lib/datadome/inquirer.rb', line 15 def build_response @validation_response.to_rack_response end |
#enriching ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/datadome/inquirer.rb', line 19 def enriching status, headers, response = yield added_headers = ::Rack::Utils::HeaderHash.new(@validation_response.response_headers) headers = ::Rack::Utils::HeaderHash.new(headers) = headers["Set-Cookie"] headers.merge!(added_headers) if added_headers["Set-Cookie"] && headers["Set-Cookie"] = (, added_headers["Set-Cookie"]) end [status, headers, response] end |
#ignore? ⇒ Boolean
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/datadome/inquirer.rb', line 36 def ignore? return false if include_matchers.empty? && exclude_matchers.empty? request = ::Rack::Request.new(@env) if include_matchers.any? any_include_matches = include_matchers.any? do |matcher| matcher.call(request.host, request.path) end return true unless any_include_matches end if exclude_matchers.any? any_exclude_matches = exclude_matchers.any? do |matcher| matcher.call(request.host, request.path) end return true if any_exclude_matches end false end |
#inquire ⇒ Object
66 67 68 |
# File 'lib/datadome/inquirer.rb', line 66 def inquire @validation_response = validate_request end |
#intercept? ⇒ Boolean
62 63 64 |
# File 'lib/datadome/inquirer.rb', line 62 def intercept? @validation_response.pass == false || @validation_response.redirect end |