Class: ZktClient::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/zkt_client/configuration.rb

Overview

Configuration class handles the configuration settings for ZktClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenString?

Retrieves the access token configuration

Returns:

  • (String, nil)

    the access token or nil if not set



36
37
38
# File 'lib/zkt_client/configuration.rb', line 36

def access_token
  @access_token || ENV["ZKT_CLIENT_ACCESS_TOKEN"]
end

#hostString?

Retrieves the host configuration

Returns:

  • (String, nil)

    the host or nil if not set



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

def host
  @host || ENV["ZKT_CLIENT_HOST"]
end

#is_object_response_enabled=(value) ⇒ Object (writeonly)

Sets the attribute is_object_response_enabled

Parameters:

  • value

    the value to set the attribute is_object_response_enabled to.



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

def is_object_response_enabled=(value)
  @is_object_response_enabled = value
end

#passwordString?

Retrieves the password configuration

Returns:

  • (String, nil)

    the password or nil if not set



29
30
31
# File 'lib/zkt_client/configuration.rb', line 29

def password
  @password || ENV["ZKT_CLIENT_PASSWORD"]
end

#usernameString?

Retrieves the username configuration

Returns:

  • (String, nil)

    the username or nil if not set



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

def username
  @username || ENV["ZKT_CLIENT_USERNAME"]
end

Instance Method Details

#configured?Boolean

Checks if the client is configured

Returns:

  • (Boolean)

    true if the client is configured, false otherwise



50
51
52
53
# File 'lib/zkt_client/configuration.rb', line 50

def configured?
  host.present? &&
    (access_token.present? || (username.present? && password.present?))
end

#with_object_response?Boolean

Checks if object response is enabled

Returns:

  • (Boolean)

    true if object response is enabled, false otherwise



43
44
45
# File 'lib/zkt_client/configuration.rb', line 43

def with_object_response?
  @is_object_response_enabled || ENV["ZKT_OBJECT_RESPONSE_ENABLED"] || false
end