Class: Coppertone::RequestContext
- Inherits:
-
Object
- Object
- Coppertone::RequestContext
- Defined in:
- lib/coppertone/request_context.rb
Overview
A container for information that should span the lifetime of an SPF check. This include the DNS client, the locale used for error messages, limits for DNS requests of different types, and limiters that ensure those limits are not exceeded across the lifetime of the request.
Instance Method Summary collapse
- #dns_client ⇒ Object
- #dns_lookups_per_mx_mechanism_limit ⇒ Object
- #dns_lookups_per_ptr_mechanism_limit ⇒ Object
-
#initialize(options = {}) ⇒ RequestContext
constructor
A new instance of RequestContext.
- #message_locale ⇒ Object
- #register_dns_lookup_term ⇒ Object
- #register_void_dns_result ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ RequestContext
Returns a new instance of RequestContext.
10 11 12 |
# File 'lib/coppertone/request_context.rb', line 10 def initialize( = {}) @options = ( || {}).dup end |
Instance Method Details
#dns_client ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/coppertone/request_context.rb', line 34 def dns_client @dns_client ||= if @options[:dns_client] @options[:dns_client] elsif @options[:dns_client_class] @options[:dns_client_class].new elsif Coppertone.config.dns_client_class Coppertone.config.dns_client_class.new else DNSAdapter::ResolvClient.new end end |
#dns_lookups_per_mx_mechanism_limit ⇒ Object
22 23 24 |
# File 'lib/coppertone/request_context.rb', line 22 def dns_lookups_per_mx_mechanism_limit config_value(:dns_lookups_per_mx_mechanism_limit) end |
#dns_lookups_per_ptr_mechanism_limit ⇒ Object
26 27 28 |
# File 'lib/coppertone/request_context.rb', line 26 def dns_lookups_per_ptr_mechanism_limit config_value(:dns_lookups_per_ptr_mechanism_limit) end |
#message_locale ⇒ Object
30 31 32 |
# File 'lib/coppertone/request_context.rb', line 30 def config_value(:message_locale) end |
#register_dns_lookup_term ⇒ Object
14 15 16 |
# File 'lib/coppertone/request_context.rb', line 14 def register_dns_lookup_term dns_lookup_term_count_limiter.increment! end |
#register_void_dns_result ⇒ Object
18 19 20 |
# File 'lib/coppertone/request_context.rb', line 18 def register_void_dns_result void_dns_result_count_limiter.increment! end |