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 11 |
# File 'lib/multiconnect/connection/base.rb', line 7 def initialize( = {}) self.client = .fetch :client, nil @except = Array(.fetch :except, []).map(&:to_sym) @only = Array(.fetch :only, []).map(&:to_sym) 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
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/multiconnect/connection/base.rb', line 21 def execute(action, *args) if allowed?(action) Result.new status: Result::SUCCESS, data: request(action, *args), connection: self.class else Result.new end rescue => e report_error(e) Result.new end |
#report_error(e) ⇒ Object
17 18 19 |
# File 'lib/multiconnect/connection/base.rb', line 17 def report_error(e) raise NotImplementedError end |
#request(action, *args) ⇒ Object
13 14 15 |
# File 'lib/multiconnect/connection/base.rb', line 13 def request(action, *args) raise NotImplementedError end |