Module: Vayacondios::Server::Driver

Included in:
MongoDriver
Defined in:
lib/vayacondios/server/driver.rb

Constant Summary collapse

Error =
Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.driversObject



8
9
10
11
12
# File 'lib/vayacondios/server/driver.rb', line 8

def drivers
  @list ||= {
    mongo: MongoDriver,
  }
end

.included(base) ⇒ Object



25
26
27
# File 'lib/vayacondios/server/driver.rb', line 25

def included base
  base.class_eval{ attr_reader :location, :log } if base.is_a? Class
end

.load_driver(handle) ⇒ Object



14
15
16
17
18
# File 'lib/vayacondios/server/driver.rb', line 14

def load_driver handle
  drivers = File.expand_path('../drivers', __FILE__)
  driver_file = File.join(drivers, handle.to_s + '.rb')
  load driver_file if File.exist? driver_file
end

.retrieve(handle) ⇒ Object



20
21
22
23
# File 'lib/vayacondios/server/driver.rb', line 20

def retrieve handle
  load_driver handle
  drivers[handle.to_sym]
end

Instance Method Details

#base_insert(request) ⇒ Object



37
38
39
# File 'lib/vayacondios/server/driver.rb', line 37

def base_insert request
  log.debug "  Processing by #{self.class}#insert"
end

#base_remove(request) ⇒ Object



53
54
55
# File 'lib/vayacondios/server/driver.rb', line 53

def base_remove request
  log.debug "  Processing by #{self.class}#remove"
end

#base_retrieve(request) ⇒ Object



41
42
43
# File 'lib/vayacondios/server/driver.rb', line 41

def base_retrieve request
  log.debug "  Processing by #{self.class}#retrieve"
end

#base_search(request) ⇒ Object



49
50
51
# File 'lib/vayacondios/server/driver.rb', line 49

def base_search request
  log.debug "  Processing by #{self.class}#search"
end

#base_update(request) ⇒ Object



45
46
47
# File 'lib/vayacondios/server/driver.rb', line 45

def base_update request
  log.debug "  Processing by #{self.class}#update"
end

#call(name, request, *options) ⇒ Object

Main api entrance method



31
32
33
34
35
# File 'lib/vayacondios/server/driver.rb', line 31

def call(name, request, *options)
  send("base_#{name}", request)
  set_location request.location
  send(name, request.document, *options)
end

#set_location(loc) ⇒ Object



57
58
59
60
# File 'lib/vayacondios/server/driver.rb', line 57

def set_location loc
  log.debug "    Location: #{loc}"
  @location = loc
end

#set_log(device) ⇒ Object



62
63
64
# File 'lib/vayacondios/server/driver.rb', line 62

def set_log device
  @log = device
end

#unset_locationObject

for testing only



67
68
69
# File 'lib/vayacondios/server/driver.rb', line 67

def unset_location
  @location = nil
end