Class: Treblle::Configuration
- Inherits:
-
Object
- Object
- Treblle::Configuration
- Defined in:
- lib/treblle/configuration.rb
Constant Summary collapse
- DEFAULT_SENSITIVE_ATTRS =
%w[ card_number cardNumber cc ccv credit_score creditScore password password_confirmation passwordConfirmation pwd secretn ssn ].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#enabled_environments ⇒ Object
Returns the value of attribute enabled_environments.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
-
#restricted_endpoints ⇒ Object
Returns the value of attribute restricted_endpoints.
-
#sensitive_attrs ⇒ Object
Returns the value of attribute sensitive_attrs.
-
#whitelisted_endpoints ⇒ Object
Returns the value of attribute whitelisted_endpoints.
Instance Method Summary collapse
- #enabled_environment? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #monitoring_enabled?(request_url) ⇒ Boolean
- #validate_credentials! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
26 27 28 29 30 31 |
# File 'lib/treblle/configuration.rb', line 26 def initialize @restricted_endpoints = [] @whitelisted_endpoints = '/api/' @app_version = nil @sensitive_attrs = DEFAULT_SENSITIVE_ATTRS end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
22 23 24 |
# File 'lib/treblle/configuration.rb', line 22 def api_key @api_key end |
#app_version ⇒ Object
Returns the value of attribute app_version.
22 23 24 |
# File 'lib/treblle/configuration.rb', line 22 def app_version @app_version end |
#enabled_environments ⇒ Object
Returns the value of attribute enabled_environments.
24 25 26 |
# File 'lib/treblle/configuration.rb', line 24 def enabled_environments @enabled_environments end |
#project_id ⇒ Object
Returns the value of attribute project_id.
22 23 24 |
# File 'lib/treblle/configuration.rb', line 22 def project_id @project_id end |
#restricted_endpoints ⇒ Object
Returns the value of attribute restricted_endpoints.
22 23 24 |
# File 'lib/treblle/configuration.rb', line 22 def restricted_endpoints @restricted_endpoints end |
#sensitive_attrs ⇒ Object
Returns the value of attribute sensitive_attrs.
24 25 26 |
# File 'lib/treblle/configuration.rb', line 24 def sensitive_attrs @sensitive_attrs end |
#whitelisted_endpoints ⇒ Object
Returns the value of attribute whitelisted_endpoints.
22 23 24 |
# File 'lib/treblle/configuration.rb', line 22 def whitelisted_endpoints @whitelisted_endpoints end |
Instance Method Details
#enabled_environment? ⇒ Boolean
45 46 47 48 49 |
# File 'lib/treblle/configuration.rb', line 45 def enabled_environment? return false if enabled_environments.empty? enabled_environments.include?(environment) end |
#monitoring_enabled?(request_url) ⇒ Boolean
33 34 35 |
# File 'lib/treblle/configuration.rb', line 33 def monitoring_enabled?(request_url) whitelisted_endpoint?(request_url) && !restricted_endpoint?(request_url) end |
#validate_credentials! ⇒ Object
51 52 53 54 |
# File 'lib/treblle/configuration.rb', line 51 def validate_credentials! raise Errors::MissingApiKeyError if api_key.to_s.empty? raise Errors::MissingProjectIdError if project_id.to_s.empty? end |