Class: Cased::Config
- Inherits:
-
Object
- Object
- Cased::Config
- Defined in:
- lib/cased/config.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
The Cased HTTP API URL.
- #cli ⇒ Object readonly
- #guard_application_key ⇒ Object
- #guard_deny_if_unreachable ⇒ Object
- #guard_user_token ⇒ Object
-
#http_open_timeout ⇒ Object
The amount of time in seconds to allow the HTTP client to open a connection.
-
#http_read_timeout ⇒ Object
The amount of time in seconds to allow the HTTP client to read a response from the server before timing out.
- #policy_keys ⇒ Object readonly
-
#publish_key ⇒ Object
Publish keys are used to publish to an audit trail.
-
#publish_url ⇒ Object
The URL to publish audit events to.
-
#raise_on_errors ⇒ Object
Policy keys are used to query for events from audit trails.
-
#silence ⇒ Object
writeonly
Configure whether or not Cased will attempt to publish any events.
-
#url ⇒ String
The Cased HTTP URL.
Instance Method Summary collapse
- #guard_deny_if_unreachable? ⇒ Boolean
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#policy_key(policy = :default) ⇒ Object
Policy keys are used to query for events from audit trails.
- #policy_key=(api_key) ⇒ Object
- #raise_on_errors? ⇒ Boolean
- #silence? ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/cased/config.rb', line 164 def initialize @http_read_timeout = ENV.fetch('CASED_HTTP_READ_TIMEOUT', 10).to_i @http_open_timeout = ENV.fetch('CASED_HTTP_OPEN_TIMEOUT', 5).to_i @raise_on_errors = !ENV['CASED_RAISE_ON_ERRORS'].nil? @url = ENV.fetch('CASED_URL', 'https://app.cased.com') @api_url = ENV.fetch('CASED_API_URL', 'https://api.cased.com') @publish_url = ENV.fetch('CASED_PUBLISH_URL', 'https://publish.cased.com') @guard_application_key = ENV['GUARD_APPLICATION_KEY'] @guard_user_token = ENV['GUARD_USER_TOKEN'] self.guard_deny_if_unreachable = ENV['DENY_IF_UNREACHABLE'] @publish_key = ENV['CASED_PUBLISH_KEY'] @silence = !ENV['CASED_SILENCE'].nil? @policy_keys = Hash.new do |hash, key| normalized_key = key.to_sym if normalized_key == :default hash[normalized_key] = ENV['CASED_POLICY_KEY'] else env_policy_name = key.to_s.tr(' ', '_').tr('-', '_').upcase api_key = ENV["CASED_#{env_policy_name}_POLICY_KEY"] hash[normalized_key] = api_key if api_key end end @cli = Cased::CLI::Config.new end |
Instance Attribute Details
#api_url ⇒ Object
The Cased HTTP API URL. Defaults to api.cased.com
53 54 55 |
# File 'lib/cased/config.rb', line 53 def api_url @api_url end |
#cli ⇒ Object (readonly)
162 163 164 |
# File 'lib/cased/config.rb', line 162 def cli @cli end |
#guard_application_key ⇒ Object
62 63 64 |
# File 'lib/cased/config.rb', line 62 def guard_application_key @guard_application_key end |
#guard_deny_if_unreachable ⇒ Object
80 81 82 |
# File 'lib/cased/config.rb', line 80 def guard_deny_if_unreachable @guard_deny_if_unreachable end |
#guard_user_token ⇒ Object
71 72 73 |
# File 'lib/cased/config.rb', line 71 def guard_user_token @guard_user_token end |
#http_open_timeout ⇒ Object
The amount of time in seconds to allow the HTTP client to open a connection.
17 18 19 |
# File 'lib/cased/config.rb', line 17 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The amount of time in seconds to allow the HTTP client to read a response from the server before timing out.
29 30 31 |
# File 'lib/cased/config.rb', line 29 def http_read_timeout @http_read_timeout end |
#policy_keys ⇒ Object (readonly)
122 123 124 |
# File 'lib/cased/config.rb', line 122 def policy_keys @policy_keys end |
#publish_key ⇒ Object
Publish keys are used to publish to an audit trail.
A publish key is associated with a single audit trail and is required if you intend to publish events to Cased in your application.
105 106 107 |
# File 'lib/cased/config.rb', line 105 def publish_key @publish_key end |
#publish_url ⇒ Object
The URL to publish audit events to. Defaults to publish.cased.com
91 92 93 |
# File 'lib/cased/config.rb', line 91 def publish_url @publish_url end |
#raise_on_errors ⇒ Object
Policy keys are used to query for events from audit trails.
133 134 135 |
# File 'lib/cased/config.rb', line 133 def raise_on_errors @raise_on_errors end |
#silence=(value) ⇒ Object (writeonly)
Configure whether or not Cased will attempt to publish any events.
If the CASED_SILENCE environment variable is not nil Cased will not publish events.
152 153 154 |
# File 'lib/cased/config.rb', line 152 def silence=(value) @silence = value end |
#url ⇒ String
The Cased HTTP URL. Defaults to app.cased.com
42 43 44 |
# File 'lib/cased/config.rb', line 42 def url @url end |
Instance Method Details
#guard_deny_if_unreachable? ⇒ Boolean
233 234 235 |
# File 'lib/cased/config.rb', line 233 def guard_deny_if_unreachable? @guard_deny_if_unreachable end |
#policy_key(policy = :default) ⇒ Object
Policy keys are used to query for events from audit trails.
201 202 203 |
# File 'lib/cased/config.rb', line 201 def policy_key(policy = :default) policy_keys[policy.to_sym] end |
#policy_key=(api_key) ⇒ Object
205 206 207 |
# File 'lib/cased/config.rb', line 205 def policy_key=(api_key) policy_keys[:default] = api_key end |
#raise_on_errors? ⇒ Boolean
221 222 223 |
# File 'lib/cased/config.rb', line 221 def raise_on_errors? @raise_on_errors end |
#silence? ⇒ Boolean
225 226 227 |
# File 'lib/cased/config.rb', line 225 def silence? @silence || !ENV['CASED_SILENCE'].nil? end |