Class: Sently::Configuration
- Inherits:
-
Object
- Object
- Sently::Configuration
- Defined in:
- lib/sently/configuration.rb
Constant Summary collapse
- OPTIONS =
[:username, :password, :http_open_timeout, :http_read_timeout, :protocol, :host, :port, :secure, :production_environment].freeze
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#http_open_timeout ⇒ Object
Returns the value of attribute http_open_timeout.
-
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#production_environment ⇒ Object
Returns the value of attribute production_environment.
-
#secure ⇒ Object
(also: #secure?)
Returns the value of attribute secure.
-
#sms_uri ⇒ Object
Returns the value of attribute sms_uri.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #[](option) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(hash) ⇒ Object
- #protocol ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
21 22 23 24 25 26 27 28 29 |
# File 'lib/sently/configuration.rb', line 21 def initialize @secure = false @host = 'sent.ly' @http_open_timeout = 10 @http_read_timeout = 10 @production_environment = true @sms_uri = '/command/sendsms' @port = default_port end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
15 16 17 |
# File 'lib/sently/configuration.rb', line 15 def host @host end |
#http_open_timeout ⇒ Object
Returns the value of attribute http_open_timeout.
13 14 15 |
# File 'lib/sently/configuration.rb', line 13 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
14 15 16 |
# File 'lib/sently/configuration.rb', line 14 def http_read_timeout @http_read_timeout end |
#password ⇒ Object
Returns the value of attribute password.
10 11 12 |
# File 'lib/sently/configuration.rb', line 10 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
16 17 18 |
# File 'lib/sently/configuration.rb', line 16 def port @port end |
#production_environment ⇒ Object
Returns the value of attribute production_environment.
17 18 19 |
# File 'lib/sently/configuration.rb', line 17 def production_environment @production_environment end |
#secure ⇒ Object Also known as: secure?
Returns the value of attribute secure.
12 13 14 |
# File 'lib/sently/configuration.rb', line 12 def secure @secure end |
#sms_uri ⇒ Object
Returns the value of attribute sms_uri.
11 12 13 |
# File 'lib/sently/configuration.rb', line 11 def sms_uri @sms_uri end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/sently/configuration.rb', line 9 def username @username end |
Instance Method Details
#[](option) ⇒ Object
31 32 33 |
# File 'lib/sently/configuration.rb', line 31 def [](option) send(option) end |
#merge(hash) ⇒ Object
41 42 43 |
# File 'lib/sently/configuration.rb', line 41 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/sently/configuration.rb', line 49 def protocol if secure? 'https' else 'http' end end |
#to_hash ⇒ Object
35 36 37 38 39 |
# File 'lib/sently/configuration.rb', line 35 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |