Class: Openlab::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/openlab/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_secret: nil) ⇒ Client



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

def initialize(app_secret: nil)
  @app_secret = app_secret || Openlab.config.app_secret

  self.class.default_options[:verify] = Openlab.config.httparty_verify
  self.class.default_options[:verify_peer] = Openlab.config.httparty_verify_peer
  self.class.base_uri Openlab.config.base_uri
  self.class.headers 'Accept' => 'application/json', 'Authorization' => "Token token=#{@app_secret}"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object



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

def method_missing(method_name, *arguments, &block)
  self.class.respond_to?(method_name) ? self.class.__send__(method_name, *arguments, &block) : super
end

Instance Attribute Details

#app_secretObject (readonly)

Returns the value of attribute app_secret.



7
8
9
# File 'lib/openlab/client.rb', line 7

def app_secret
  @app_secret
end

Instance Method Details

#projectsObject



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

def projects
  @projects ||= Openlab::Projects.new(self)
end

#respond_to?(method_name, include_private = false) ⇒ Boolean



27
28
29
# File 'lib/openlab/client.rb', line 27

def respond_to?(method_name, include_private = false)
  self.class.respond_to?(method_name) || super
end