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

Returns a new instance of Client.



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

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

  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



21
22
23
# File 'lib/openlab/client.rb', line 21

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.



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

def app_secret
  @app_secret
end

Instance Method Details

#projectsObject



17
18
19
# File 'lib/openlab/client.rb', line 17

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

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/openlab/client.rb', line 25

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