Class: SmsTraffic::Configuration
- Inherits:
-
Object
- Object
- SmsTraffic::Configuration
- Includes:
- Singleton
- Defined in:
- lib/sms_traffic/configuration.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#login ⇒ Object
Returns the value of attribute login.
-
#originator ⇒ Object
Returns the value of attribute originator.
-
#password ⇒ Object
Returns the value of attribute password.
-
#validate_phone ⇒ Object
Returns the value of attribute validate_phone.
-
#xml_parser ⇒ Object
Returns the value of attribute xml_parser.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset! ⇒ Object
- #to_h ⇒ Object
- #validate! ⇒ Object
- #values_at(*keys) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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
#debug ⇒ Object
Returns the value of attribute debug.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def debug @debug end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def logger @logger end |
#login ⇒ Object
Returns the value of attribute login.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def login @login end |
#originator ⇒ Object
Returns the value of attribute originator.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def originator @originator end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/sms_traffic/configuration.rb', line 8 def password @password end |
#validate_phone ⇒ Object
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_parser ⇒ Object
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_h ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sms_traffic/configuration.rb', line 30 def to_h { login: 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 |