Class: Moonshado::Configuration
- Inherits:
-
Object
- Object
- Moonshado::Configuration
- Defined in:
- lib/moonshado/configuration.rb
Constant Summary collapse
- OPTIONS =
[:api_key, :keywords, :sms_uri, :keyword_uri, :auto_register_keyword, :host, :http_open_timeout, :http_read_timeout, :port, :protocol, :secure, :production_environment].freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#auto_register_keywords ⇒ Object
Returns the value of attribute auto_register_keywords.
-
#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.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#keywords_uri ⇒ Object
Returns the value of attribute keywords_uri.
-
#message_length_check ⇒ Object
(also: #message_length_check?)
Returns the value of attribute message_length_check.
-
#message_length_range ⇒ Object
Returns the value of attribute message_length_range.
-
#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.
Instance Method Summary collapse
- #[](option) ⇒ Object
- #formatted_api_key ⇒ 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.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/moonshado/configuration.rb', line 27 def initialize @secure = false @host = 'heroku.moonshado.com' @http_open_timeout = 10 @http_read_timeout = 10 @production_environment = true @sms_uri = '/sms' @keywords_uri = '/keywords' @auto_register_keywords = false @port = default_port @message_length_range = 3..115 @message_length_check = true end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/moonshado/configuration.rb', line 10 def api_key @api_key end |
#auto_register_keywords ⇒ Object
Returns the value of attribute auto_register_keywords.
18 19 20 |
# File 'lib/moonshado/configuration.rb', line 18 def auto_register_keywords @auto_register_keywords end |
#host ⇒ Object
Returns the value of attribute host.
17 18 19 |
# File 'lib/moonshado/configuration.rb', line 17 def host @host end |
#http_open_timeout ⇒ Object
Returns the value of attribute http_open_timeout.
15 16 17 |
# File 'lib/moonshado/configuration.rb', line 15 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
16 17 18 |
# File 'lib/moonshado/configuration.rb', line 16 def http_read_timeout @http_read_timeout end |
#keywords ⇒ Object
Returns the value of attribute keywords.
11 12 13 |
# File 'lib/moonshado/configuration.rb', line 11 def keywords @keywords end |
#keywords_uri ⇒ Object
Returns the value of attribute keywords_uri.
13 14 15 |
# File 'lib/moonshado/configuration.rb', line 13 def keywords_uri @keywords_uri end |
#message_length_check ⇒ Object Also known as: message_length_check?
Returns the value of attribute message_length_check.
22 23 24 |
# File 'lib/moonshado/configuration.rb', line 22 def @message_length_check end |
#message_length_range ⇒ Object
Returns the value of attribute message_length_range.
21 22 23 |
# File 'lib/moonshado/configuration.rb', line 21 def @message_length_range end |
#port ⇒ Object
Returns the value of attribute port.
20 21 22 |
# File 'lib/moonshado/configuration.rb', line 20 def port @port end |
#production_environment ⇒ Object
Returns the value of attribute production_environment.
19 20 21 |
# File 'lib/moonshado/configuration.rb', line 19 def production_environment @production_environment end |
#secure ⇒ Object Also known as: secure?
Returns the value of attribute secure.
14 15 16 |
# File 'lib/moonshado/configuration.rb', line 14 def secure @secure end |
#sms_uri ⇒ Object
Returns the value of attribute sms_uri.
12 13 14 |
# File 'lib/moonshado/configuration.rb', line 12 def sms_uri @sms_uri end |
Instance Method Details
#[](option) ⇒ Object
55 56 57 |
# File 'lib/moonshado/configuration.rb', line 55 def [](option) send(option) end |
#formatted_api_key ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/moonshado/configuration.rb', line 45 def formatted_api_key url_obj = URI.parse(@api_key) if (url_obj.class == URI::Generic) @api_key else url_obj.user end end |
#merge(hash) ⇒ Object
65 66 67 |
# File 'lib/moonshado/configuration.rb', line 65 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/moonshado/configuration.rb', line 73 def protocol if secure? 'https' else 'http' end end |
#to_hash ⇒ Object
59 60 61 62 63 |
# File 'lib/moonshado/configuration.rb', line 59 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |