Class: FlyingSphinx::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/flying_sphinx/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(identifier = nil, api_key = nil) ⇒ Configuration

Returns a new instance of Configuration.



2
3
4
5
# File 'lib/flying_sphinx/configuration.rb', line 2

def initialize(identifier = nil, api_key = nil)
  @identifier = identifier || identifier_from_env
  @api_key    = api_key    || api_key_from_env
end

Instance Method Details

#apiObject



7
8
9
# File 'lib/flying_sphinx/configuration.rb', line 7

def api
  @api ||= FlyingSphinx::API.new(identifier, api_key)
end

#client_keyObject



11
12
13
# File 'lib/flying_sphinx/configuration.rb', line 11

def client_key
  "#{identifier}:#{api_key}"
end

#hostObject



15
16
17
# File 'lib/flying_sphinx/configuration.rb', line 15

def host
  @host ||= response_body['server'] rescue host_from_env
end

#portObject



19
20
21
# File 'lib/flying_sphinx/configuration.rb', line 19

def port
  @port ||= response_body['port'] rescue port_from_env
end

#usernameObject



23
24
25
# File 'lib/flying_sphinx/configuration.rb', line 23

def username
  "#{identifier}#{api_key}"
end