Class: Clowk::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/clowk/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/clowk/configuration.rb', line 26

def initialize
  @api_base_url = "https://api.clowk.dev/api/v1"
  @app_base_url = "https://app.clowk.in"
  @after_sign_in_path = "/"
  @after_sign_out_path = "/"
  @mount_path = "/clowk"
  @callback_path = "/clowk/oauth/callback"
  @cookie_key = "clowk_token"
  @http_logger = nil
  @http_open_timeout = 5
  @http_read_timeout = 10
  @http_retry_attempts = 2
  @http_retry_interval = 0.05
  @http_write_timeout = 10
  @issuer = "clowk"
  @session_key = :clowk
  @prefix_by = :clowk
  @token_param = :token
  @enforce_active_session = false
  @on_session_expired = nil
end

Instance Attribute Details

#after_sign_in_pathObject



48
49
50
# File 'lib/clowk/configuration.rb', line 48

def 
  resolve_path(@after_sign_in_path)
end

#after_sign_out_pathObject



52
53
54
# File 'lib/clowk/configuration.rb', line 52

def after_sign_out_path
  resolve_path(@after_sign_out_path)
end

#api_base_urlObject

Returns the value of attribute api_base_url.



5
6
7
# File 'lib/clowk/configuration.rb', line 5

def api_base_url
  @api_base_url
end

#app_base_urlObject

Returns the value of attribute app_base_url.



6
7
8
# File 'lib/clowk/configuration.rb', line 6

def app_base_url
  @app_base_url
end

#callback_pathObject

Returns the value of attribute callback_path.



7
8
9
# File 'lib/clowk/configuration.rb', line 7

def callback_path
  @callback_path
end

Returns the value of attribute cookie_key.



8
9
10
# File 'lib/clowk/configuration.rb', line 8

def cookie_key
  @cookie_key
end

#enforce_active_sessionObject

Returns the value of attribute enforce_active_session.



23
24
25
# File 'lib/clowk/configuration.rb', line 23

def enforce_active_session
  @enforce_active_session
end

#http_loggerObject

Returns the value of attribute http_logger.



9
10
11
# File 'lib/clowk/configuration.rb', line 9

def http_logger
  @http_logger
end

#http_open_timeoutObject

Returns the value of attribute http_open_timeout.



10
11
12
# File 'lib/clowk/configuration.rb', line 10

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject

Returns the value of attribute http_read_timeout.



11
12
13
# File 'lib/clowk/configuration.rb', line 11

def http_read_timeout
  @http_read_timeout
end

#http_retry_attemptsObject

Returns the value of attribute http_retry_attempts.



12
13
14
# File 'lib/clowk/configuration.rb', line 12

def http_retry_attempts
  @http_retry_attempts
end

#http_retry_intervalObject

Returns the value of attribute http_retry_interval.



13
14
15
# File 'lib/clowk/configuration.rb', line 13

def http_retry_interval
  @http_retry_interval
end

#http_write_timeoutObject

Returns the value of attribute http_write_timeout.



14
15
16
# File 'lib/clowk/configuration.rb', line 14

def http_write_timeout
  @http_write_timeout
end

#issuerObject

Returns the value of attribute issuer.



15
16
17
# File 'lib/clowk/configuration.rb', line 15

def issuer
  @issuer
end

#mount_pathObject

Returns the value of attribute mount_path.



16
17
18
# File 'lib/clowk/configuration.rb', line 16

def mount_path
  @mount_path
end

#on_session_expiredObject

Returns the value of attribute on_session_expired.



24
25
26
# File 'lib/clowk/configuration.rb', line 24

def on_session_expired
  @on_session_expired
end

#prefix_byObject

Returns the value of attribute prefix_by.



18
19
20
# File 'lib/clowk/configuration.rb', line 18

def prefix_by
  @prefix_by
end

#publishable_keyObject

Returns the value of attribute publishable_key.



17
18
19
# File 'lib/clowk/configuration.rb', line 17

def publishable_key
  @publishable_key
end

#secret_keyObject

Returns the value of attribute secret_key.



19
20
21
# File 'lib/clowk/configuration.rb', line 19

def secret_key
  @secret_key
end

#session_keyObject

Returns the value of attribute session_key.



20
21
22
# File 'lib/clowk/configuration.rb', line 20

def session_key
  @session_key
end

#subdomain_urlObject

Returns the value of attribute subdomain_url.



21
22
23
# File 'lib/clowk/configuration.rb', line 21

def subdomain_url
  @subdomain_url
end

#token_paramObject

Returns the value of attribute token_param.



22
23
24
# File 'lib/clowk/configuration.rb', line 22

def token_param
  @token_param
end

Instance Method Details

#validate!Object

Raises:



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/clowk/configuration.rb', line 60

def validate!
  errors = []
  errors << "secret_key must be a String" unless @secret_key.is_a?(String) || @secret_key.nil?
  errors << "http_open_timeout must be Numeric" unless @http_open_timeout.is_a?(Numeric)
  errors << "http_read_timeout must be Numeric" unless @http_read_timeout.is_a?(Numeric)
  errors << "http_write_timeout must be Numeric" unless @http_write_timeout.is_a?(Numeric)
  errors << "http_retry_attempts must be a non-negative Integer" unless @http_retry_attempts.is_a?(Integer) && @http_retry_attempts >= 0

  raise ConfigurationError, errors.join(", ") if errors.any?

  true
end