Class: Minds::Client

Inherits:
Object
  • Object
show all
Includes:
RestClient
Defined in:
lib/minds/client.rb

Constant Summary collapse

SENSITIVE_ATTRIBUTES =
%i[@base_url @api_key].freeze
CONFIG_KEYS =
%i[base_url api_key log_errors api_version].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RestClient

#delete, #get, #patch, #post, #put

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
# File 'lib/minds/client.rb', line 11

def initialize(options = {})
  # if key not present. Fall back to global config
  CONFIG_KEYS.each do |key|
    instance_variable_set "@#{key}", options[key] || Client.config.send(key)
  end
end

Class Method Details

.configObject



19
20
21
# File 'lib/minds/client.rb', line 19

def config
  @config ||= Config::Base.new
end

.configure {|config| ... } ⇒ Object

Yields:



23
24
25
# File 'lib/minds/client.rb', line 23

def configure
  yield(config) if block_given?
end

Instance Method Details

#datasourcesObject



28
29
30
# File 'lib/minds/client.rb', line 28

def datasources
  @datasources ||= Datasources.new(client: self)
end

#inspectObject



36
37
38
39
40
41
42
43
44
# File 'lib/minds/client.rb', line 36

def inspect
  vars = instance_variables.map do |var|
    value = instance_variable_get(var)

    SENSITIVE_ATTRIBUTES.include?(var) ? "#{var}=[FILTERED]" : "#{var}=#{value.inspect}"
  end

  "#<#{self.class}:0x#{object_id.to_s(16)} #{vars.join(', ')}>"
end

#mindsObject



32
33
34
# File 'lib/minds/client.rb', line 32

def minds
  @minds ||= Minds.new(client: self)
end