class Elastify::Config

Attributes

connection[RW]

Public Class Methods

new() click to toggle source
# File lib/elastify/config.rb, line 6
def initialize
    @connection = OpenStruct.new({protocol: 'http', host: 'localhost', port: '9200'})
end

Public Instance Methods

base_url() click to toggle source
# File lib/elastify/config.rb, line 18
def base_url
    "#{@connection.protocol}://#{@connection.host}:#{@connection.port}"
end
base_url=(uri) click to toggle source
# 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