Module: SmsBroker::Configuration

Extended by:
Configuration
Included in:
SmsBroker, Configuration
Defined in:
lib/sms_broker/configuration.rb

Instance Method Summary collapse

Instance Method Details

#clear_setupObject



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

def clear_setup
  @configuration = nil
end

#configurationObject



18
19
20
21
22
23
# File 'lib/sms_broker/configuration.rb', line 18

def configuration
  exception = \
    Exceptions::InvalidSetup.new('setup does not exists')

  @configuration || (raise exception)
end

#default_serviceObject



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

def default_service
  configuration[:default_service]
end

#setup {|setup| ... } ⇒ Object

Yields:



25
26
27
28
29
30
31
32
# File 'lib/sms_broker/configuration.rb', line 25

def setup
  setup = Setup.new
  yield setup if block_given?

  @configuration = setup.options

  setup
end

#setup! {|setup| ... } ⇒ Object

Yields:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sms_broker/configuration.rb', line 34

def setup!
  setup = Setup.new
  yield setup if block_given?

  unless setup.valid?
    exception = \
      Exceptions::InvalidSetup.new("setup is invalid, #{setup.errors}")

    exception.errors = setup.errors

    raise exception
  end

  @configuration = setup.options

  setup
end