Class: Driver::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/driver/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Client

Returns a new instance of Client.



35
36
37
# File 'lib/driver/client.rb', line 35

def initialize(api)
  @api = api
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



33
34
35
# File 'lib/driver/client.rb', line 33

def api
  @api
end

Class Method Details

.const_missing(name) ⇒ Object



4
5
6
# File 'lib/driver/client.rb', line 4

def const_missing(name)
  name
end

.drive(*modules) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/driver/client.rb', line 8

def drive(*modules)
  # api
  autoload :API, "#{self}/api".underscore

  modules.each_with_index do |m, i|
    # client
    autoload m, "#{self}::#{m}".underscore

    modules[i] = "#{self}::#{m}".constantize
  end

  include *modules
end

.model(*modules) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/driver/client.rb', line 22

def model(*modules)
  modules.each_with_index do |m, i|
    # model
    module_name = self.to_s.sub("::#{self.to_s.demodulize}", '').constantize
    module_name.autoload m, "#{self}::Model::#{m}".underscore
  end

  Driver::Model.concerns
end