Module: Gensee::Configurable

Included in:
Gensee
Defined in:
lib/gensee/configurable.rb

Constant Summary collapse

USER_AGENT =
"Gensee Ruby Gem #{Gensee::VERSION}".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



3
4
5
# File 'lib/gensee/configurable.rb', line 3

def endpoint
  @endpoint
end

#loginObject

Returns the value of attribute login.



3
4
5
# File 'lib/gensee/configurable.rb', line 3

def 
  @login
end

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/gensee/configurable.rb', line 3

def password
  @password
end

Class Method Details

.default_optionsObject



13
14
15
16
17
18
19
# File 'lib/gensee/configurable.rb', line 13

def default_options
  {
    endpoint: ENV['GENSEE_ENDPOINT'],
    login: ENV['GENSEE_LOGIN'],
    password: ENV['GENSEE_PASSWORD']
  }
end

.keysArray

List all keys

Returns:

  • (Array)


9
10
11
# File 'lib/gensee/configurable.rb', line 9

def keys
  @keys ||= [:endpoint, :login, :password]
end

.user_agentObject



21
22
23
# File 'lib/gensee/configurable.rb', line 21

def user_agent
  ENV['GENSEE_USER_AGENT'] || USER_AGENT
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



34
35
36
# File 'lib/gensee/configurable.rb', line 34

def configure
  yield self
end

#optionsObject



26
27
28
29
30
31
# File 'lib/gensee/configurable.rb', line 26

def options
  ary = Gensee::Configurable.keys.map do |key|
    [key, send(key) || Gensee::Configurable.default_options[key]]
  end
  Hash[ary]
end