Class: SmsTraffic::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
# File 'lib/sms_traffic/configuration.rb', line 10

def initialize
  self.debug          = default_configuration[:debug]
  self.logger         = default_configuration[:logger]
  self.xml_parser     = default_configuration[:xml_parser]
  self.validate_phone = default_configuration[:validate_phone]
  super
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#loginObject

Returns the value of attribute login.



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

def 
  @login
end

#originatorObject

Returns the value of attribute originator.



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

def originator
  @originator
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#validate_phoneObject

Returns the value of attribute validate_phone.



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

def validate_phone
  @validate_phone
end

#xml_parserObject

Returns the value of attribute xml_parser.



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

def xml_parser
  @xml_parser
end

Instance Method Details

#reset!Object



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

def reset!
  default_configuration.each do |key, value|
    send("#{key}=", value)
  end
end

#to_hObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sms_traffic/configuration.rb', line 30

def to_h
  {
    login:      ,
    password:   password,
    host:       host,
    originator: originator,
    debug:      debug,
    logger:     logger,
    xml_parser: xml_parser
  }
end

#validate!Object



24
25
26
27
28
# File 'lib/sms_traffic/configuration.rb', line 24

def validate!
  validation_rules.each do |key, value|
    raise ArgumentError, "#{key} should be defined for #{self}." if value.nil?
  end
end

#values_at(*keys) ⇒ Object



42
43
44
# File 'lib/sms_traffic/configuration.rb', line 42

def values_at(*keys)
  to_h.values_at(*keys)
end