Class: VTools::Storage
- Inherits:
-
Object
- Object
- VTools::Storage
- Includes:
- SharedMethods
- Defined in:
- lib/vtools/storage.rb
Overview
Interface API to the Message Queue or Database Server (AdapterInterface)
Class Method Summary collapse
-
.connect ⇒ Object
creates connection.
-
.connect_action(&block) ⇒ Object
callback setter to connect to the storage.
-
.recv ⇒ Object
receive basic method.
-
.recv_action(&block) ⇒ Object
callback setter to receive data.
-
.send(data) ⇒ Object
send basic method.
-
.send_action(&block) ⇒ Object
callback setter to send data when done successfully Storage#send will pass Hash with content: :data => Job.execution_result, :action => Job.executed_action.
-
.setup(&block) ⇒ Object
callback setter for the collection usage: VTools::Storage.setup do connect_action { … } send_action { |data| … } recv_action { … }.
Methods included from SharedMethods
Methods included from VTools::SharedMethods::Common
#config, #fix_encoding, #generate_path, #hash_to_obj, #json_to_obj, #keys_to_sym, #log, #logger=, #network_call, #parse_json, #path_generator
Class Method Details
.connect ⇒ Object
creates connection
14 15 16 17 |
# File 'lib/vtools/storage.rb', line 14 def connect fails __method__ unless @actions[:connect] @actions[:connect].call end |
.connect_action(&block) ⇒ Object
callback setter to connect to the storage
32 33 34 |
# File 'lib/vtools/storage.rb', line 32 def connect_action &block @actions[:connect] = block end |
.recv ⇒ Object
receive basic method
20 21 22 23 |
# File 'lib/vtools/storage.rb', line 20 def recv fails __method__ unless @actions[:recv] @actions[:recv].call end |
.recv_action(&block) ⇒ Object
callback setter to receive data
37 38 39 |
# File 'lib/vtools/storage.rb', line 37 def recv_action &block @actions[:recv] = block end |
.send(data) ⇒ Object
send basic method
26 27 28 29 |
# File 'lib/vtools/storage.rb', line 26 def send data fails __method__ unless @actions[:send] @actions[:send].call(data) end |
.send_action(&block) ⇒ Object
callback setter to send data when done successfully Storage#send will pass Hash with content:
:data => Job.execution_result,
:action => Job.executed_action
45 46 47 |
# File 'lib/vtools/storage.rb', line 45 def send_action &block @actions[:send] = block end |
.setup(&block) ⇒ Object
callback setter for the collection usage: VTools::Storage.setup do
connect_action { ... }
send_action { |data| ... }
recv_action { ... }
55 56 57 |
# File 'lib/vtools/storage.rb', line 55 def setup &block instance_eval &block if block_given? end |