Class: Trackets::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_keyObject

Returns the value of attribute api_key.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def api_key
  @api_key
end

#api_urlObject

Returns the value of attribute api_url.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def api_url
  @api_url
end

#asyncObject 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_paramsObject

Returns the value of attribute blacklisted_params.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def blacklisted_params
  @blacklisted_params
end

#environment_nameObject

Returns the value of attribute environment_name.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def environment_name
  @environment_name
end

#frameworkObject

Returns the value of attribute framework.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def framework
  @framework
end

#project_rootObject

Returns the value of attribute project_root.



30
31
32
# File 'lib/trackets/configuration.rb', line 30

def project_root
  @project_root
end

#whitelisted_envObject

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

Returns:

  • (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