Class: Multiconnect::Connection::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/multiconnect/connection/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
# File 'lib/multiconnect/connection/base.rb', line 7

def initialize(options = {})
  self.client = options.fetch :client, nil
  @except = Array(options.fetch :except, [])
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/multiconnect/connection/base.rb', line 5

def client
  @client
end

Instance Method Details

#execute(action, *args) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/multiconnect/connection/base.rb', line 20

def execute(action, *args)
  if @except.include? action
    Result.new 
  else
    Result.new status: Result::SUCCESS, data: request(action, *args), connection: self.class
  end

rescue => e
  report_error(e)
  Result.new
end

#report_error(e) ⇒ Object

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/multiconnect/connection/base.rb', line 16

def report_error(e)
  raise NotImplementedError
end

#request(action, *args) ⇒ Object

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/multiconnect/connection/base.rb', line 12

def request(action, *args)
  raise NotImplementedError
end