Class: Rack::SnapSearch::Config
- Inherits:
-
Object
- Object
- Rack::SnapSearch::Config
- Defined in:
- lib/rack/snap_search/config.rb
Overview
The configuration class for the Rack middleware. Holds the attributes to initialize the Client, Interceptor, and Detector with.
Constant Summary collapse
- ATTRIBUTES =
[ :email, :key, :api_url, :ca_cert_file, :x_forwarded_proto, :parameters, # Client options :matched_routes, :ignored_routes, :robots_json, :extensions_json, :check_file_extensions # Detector options ]
Instance Method Summary collapse
-
#after_intercept { ... } ⇒ Proc
Getter/Setter for the ‘after_intercept` attribute on the Interceptor.
-
#before_intercept { ... } ⇒ Proc
Getter/Setter for the ‘before_intercept` attribute on the Interceptor.
-
#initialize(options = {}) ⇒ Config
constructor
Create a new instance.
-
#on_exception { ... } ⇒ Proc
Getter/Setter for the ‘on_exception` attribute.
-
#response_callback { ... } ⇒ Proc
Getter/Setter for the ‘response_callback` attribute on the Interceptor.
Constructor Details
#initialize(options = {}) ⇒ Config
Create a new instance.
33 34 35 36 37 38 39 40 |
# File 'lib/rack/snap_search/config.rb', line 33 def initialize(={}) raise TypeError, 'options must be a Hash or respond to #to_h' unless .is_a?(Hash) || .respond_to?(:to_h) || .respond_to?(:to_hash) = .to_h rescue .to_hash ATTRIBUTES.each do |attribute| send( "#{attribute}=", [attribute] ) if .has_key?(attribute) end end |
Instance Method Details
#after_intercept { ... } ⇒ Proc
Getter/Setter for the ‘after_intercept` attribute on the Interceptor.
66 67 68 69 70 |
# File 'lib/rack/snap_search/config.rb', line 66 def after_intercept(&block) @after_intercept = block if block_given? @after_intercept end |
#before_intercept { ... } ⇒ Proc
Getter/Setter for the ‘before_intercept` attribute on the Interceptor.
56 57 58 59 60 |
# File 'lib/rack/snap_search/config.rb', line 56 def before_intercept(&block) @before_intercept = block if block_given? @before_intercept end |
#on_exception { ... } ⇒ Proc
Getter/Setter for the ‘on_exception` attribute.
46 47 48 49 50 |
# File 'lib/rack/snap_search/config.rb', line 46 def on_exception(&block) @on_exception = block if block_given? @on_exception end |
#response_callback { ... } ⇒ Proc
Getter/Setter for the ‘response_callback` attribute on the Interceptor.
76 77 78 79 80 |
# File 'lib/rack/snap_search/config.rb', line 76 def response_callback(&block) @response_callback = block if block_given? @response_callback end |