Class: Elastify::Config
- Inherits:
-
Object
- Object
- Elastify::Config
- Defined in:
- lib/elastify/config.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Instance Method Summary collapse
- #base_url ⇒ Object
- #base_url=(uri) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 |
# File 'lib/elastify/config.rb', line 6 def initialize @connection = OpenStruct.new({protocol: 'http', host: 'localhost', port: '9200'}) end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
4 5 6 |
# File 'lib/elastify/config.rb', line 4 def connection @connection end |
Instance Method Details
#base_url ⇒ Object
18 19 20 |
# File 'lib/elastify/config.rb', line 18 def base_url "#{@connection.protocol}://#{@connection.host}:#{@connection.port}" end |
#base_url=(uri) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/elastify/config.rb', line 10 def base_url=(uri) m1 = /(http|https)\:\/\/([A-z0-9\_\-\.]+)\:([0-9]+)/.match(uri) raise ArgumentError, 'Invalid URI' unless m1.present? @connection.protocol = m1[1] @connection.host = m1[2] @connection.port = m1[3] end |