Class: Multiconnect::Connection::Base
- Inherits:
-
Object
- Object
- Multiconnect::Connection::Base
- Defined in:
- lib/multiconnect/connection/base.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #execute(action, *args) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #report_error(e) ⇒ Object
- #request(action, *args) ⇒ Object
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( = {}) self.client = .fetch :client, nil @except = Array(.fetch :except, []) end |
Instance Attribute Details
#client ⇒ Object
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
16 17 18 |
# File 'lib/multiconnect/connection/base.rb', line 16 def report_error(e) raise NotImplementedError end |
#request(action, *args) ⇒ Object
12 13 14 |
# File 'lib/multiconnect/connection/base.rb', line 12 def request(action, *args) raise NotImplementedError end |