Class: Broadcast::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/broadcast/configuration.rb', line 15

def initialize
  @api_token = nil
  @host = 'https://sendbroadcast.com'
  @timeout = 30
  @open_timeout = 10
  @retry_attempts = 3
  @retry_delay = 1
  @logger = nil
  @debug = false
  @broadcast_channel_id = nil
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



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

def api_token
  @api_token
end

#broadcast_channel_idObject

Returns the value of attribute broadcast_channel_id.



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

def broadcast_channel_id
  @broadcast_channel_id
end

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#open_timeoutObject

Returns the value of attribute open_timeout.



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

def open_timeout
  @open_timeout
end

#retry_attemptsObject

Returns the value of attribute retry_attempts.



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

def retry_attempts
  @retry_attempts
end

#retry_delayObject

Returns the value of attribute retry_delay.



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

def retry_delay
  @retry_delay
end

#timeoutObject

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Instance Method Details

#validate!Object

Raises:



27
28
29
30
31
# File 'lib/broadcast/configuration.rb', line 27

def validate!
  raise ConfigurationError, 'api_token is required' if api_token.nil? || api_token.to_s.strip.empty?

  self.host = host.chomp('/') if host&.end_with?('/')
end