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"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#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.
-
#environment_name ⇒ Object
Returns the value of attribute environment_name.
-
#framework ⇒ Object
Returns the value of attribute framework.
-
#project_root ⇒ Object
Returns the value of attribute project_root.
-
#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
-
#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.
33 34 35 36 37 38 |
# File 'lib/trackets/configuration.rb', line 33 def initialize @api_url = DEFAULT_API_URL @whitelisted_env = DEFAULT_WHITELISTED_ENV_KEYS @blacklisted_params = DEFAULT_BLACKLISTED_PARAMS @async = false end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def api_key @api_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def api_url @api_url end |
#async ⇒ Object Also known as: async?
Returns the value of attribute async.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def async @async end |
#blacklisted_params ⇒ Object
Returns the value of attribute blacklisted_params.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def blacklisted_params @blacklisted_params end |
#environment_name ⇒ Object
Returns the value of attribute environment_name.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def environment_name @environment_name end |
#framework ⇒ Object
Returns the value of attribute framework.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def framework @framework end |
#project_root ⇒ Object
Returns the value of attribute project_root.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def project_root @project_root end |
#whitelisted_env ⇒ Object
Returns the value of attribute whitelisted_env.
30 31 32 |
# File 'lib/trackets/configuration.rb', line 30 def whitelisted_env @whitelisted_env end |
Instance Method Details
#blacklisted_key?(key, rack_env = nil) ⇒ Boolean
48 49 50 |
# File 'lib/trackets/configuration.rb', line 48 def blacklisted_key?(key, rack_env = nil) blacklisted_keys.include?(key) end |
#blacklisted_keys(rack_env = nil) ⇒ Object
44 45 46 |
# File 'lib/trackets/configuration.rb', line 44 def blacklisted_keys(rack_env = nil) @blacklisted_keys ||= (blacklisted_params + rack_filter_keys).map(&:to_s) end |
#rack_filter_keys(rack_env = nil) ⇒ Object
40 41 42 |
# File 'lib/trackets/configuration.rb', line 40 def rack_filter_keys(rack_env = nil) @rack_filter_keys ||= rack_env ? Array(rack_env["action_dispatch.parameter_filter"]) : [] end |