Class: Trackets::Configuration
- Inherits:
-
Object
- Object
- Trackets::Configuration
- Defined in:
- lib/trackets/configuration.rb
Constant Summary collapse
- DEFAULT_WHITELISTED_ENV_KEYS =
[ "REQUEST_METHOD", "PATH_INFO", "QUERY_STRING", "SCRIPT_NAME", "REMOTE_ADDR", "SERVER_ADDR", "SERVER_NAME", "SERVER_PORT", "HTTP_HOST", "HTTP_CONNECTION", "CONTENT_LENGTH", "HTTP_ACCEPT", "HTTP_ORIGIN", "HTTP_USER_AGENT", "CONTENT_TYPE", "HTTP_REFERER", "HTTP_ACCEPT_ENCODING", "HTTP_ACCEPT_LANGUAGE", "REMOTE_PORT", "ORIGINAL_FULLPATH" ].freeze
- DEFAULT_BLACKLISTED_PARAMS =
["password", "password_confirmation", "card_number", "cvv"].freeze
- DEFAULT_API_URL =
"https://trackets.com"- DEFAULT_LOAD_PLUGINS =
[:sidekiq]
- DEFAULT_ENABLED_ENV =
[:production]
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#async ⇒ Object
(also: #async?)
Returns the value of attribute async.
-
#blacklisted_params ⇒ Object
Returns the value of attribute blacklisted_params.
-
#enabled_env ⇒ Object
Returns the value of attribute enabled_env.
-
#environment_name ⇒ Object
Returns the value of attribute environment_name.
-
#force ⇒ Object
(also: #force?)
Returns the value of attribute force.
-
#framework ⇒ Object
Returns the value of attribute framework.
-
#load_plugins ⇒ Object
Returns the value of attribute load_plugins.
-
#private_api_key ⇒ Object
Returns the value of attribute private_api_key.
-
#project_root ⇒ Object
Returns the value of attribute project_root.
-
#public_api_key ⇒ Object
Returns the value of attribute public_api_key.
-
#whitelisted_env ⇒ Object
Returns the value of attribute whitelisted_env.
Instance Method Summary collapse
- #blacklisted_key?(key, rack_env = nil) ⇒ Boolean
- #blacklisted_keys(rack_env = nil) ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #rack_filter_keys(rack_env = nil) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
37 38 39 40 41 42 43 44 45 |
# File 'lib/trackets/configuration.rb', line 37 def initialize @api_url = DEFAULT_API_URL @whitelisted_env = DEFAULT_WHITELISTED_ENV_KEYS @blacklisted_params = DEFAULT_BLACKLISTED_PARAMS @async = false @load_plugins = DEFAULT_LOAD_PLUGINS @enabled_env = DEFAULT_ENABLED_ENV @force = false end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def api_url @api_url end |
#async ⇒ Object Also known as: async?
Returns the value of attribute async.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def async @async end |
#blacklisted_params ⇒ Object
Returns the value of attribute blacklisted_params.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def blacklisted_params @blacklisted_params end |
#enabled_env ⇒ Object
Returns the value of attribute enabled_env.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def enabled_env @enabled_env end |
#environment_name ⇒ Object
Returns the value of attribute environment_name.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def environment_name @environment_name end |
#force ⇒ Object Also known as: force?
Returns the value of attribute force.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def force @force end |
#framework ⇒ Object
Returns the value of attribute framework.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def framework @framework end |
#load_plugins ⇒ Object
Returns the value of attribute load_plugins.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def load_plugins @load_plugins end |
#private_api_key ⇒ Object
Returns the value of attribute private_api_key.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def private_api_key @private_api_key end |
#project_root ⇒ Object
Returns the value of attribute project_root.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def project_root @project_root end |
#public_api_key ⇒ Object
Returns the value of attribute public_api_key.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def public_api_key @public_api_key end |
#whitelisted_env ⇒ Object
Returns the value of attribute whitelisted_env.
31 32 33 |
# File 'lib/trackets/configuration.rb', line 31 def whitelisted_env @whitelisted_env end |
Instance Method Details
#blacklisted_key?(key, rack_env = nil) ⇒ Boolean
55 56 57 |
# File 'lib/trackets/configuration.rb', line 55 def blacklisted_key?(key, rack_env = nil) blacklisted_keys.include?(key) end |
#blacklisted_keys(rack_env = nil) ⇒ Object
51 52 53 |
# File 'lib/trackets/configuration.rb', line 51 def blacklisted_keys(rack_env = nil) @blacklisted_keys ||= (blacklisted_params + rack_filter_keys).map(&:to_s) end |
#enabled? ⇒ Boolean
59 60 61 |
# File 'lib/trackets/configuration.rb', line 59 def enabled? enabled_env.include?(environment_name.to_sym) || force? end |
#rack_filter_keys(rack_env = nil) ⇒ Object
47 48 49 |
# File 'lib/trackets/configuration.rb', line 47 def rack_filter_keys(rack_env = nil) @rack_filter_keys ||= rack_env ? Array(rack_env["action_dispatch.parameter_filter"]) : [] end |