Class: SubZero::Client
- Inherits:
-
Object
- Object
- SubZero::Client
- Includes:
- Socket
- Defined in:
- lib/sub_zero/client.rb,
lib/sub_zero/client/socket.rb,
lib/sub_zero/client/configuration.rb
Defined Under Namespace
Modules: Configuration, Socket Classes: Error
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#sid ⇒ Object
readonly
Returns the value of attribute sid.
Instance Method Summary collapse
- #[](verb) ⇒ Object
- #call(verb, payload = {}, options = {}) ⇒ Object
- #call!(verb, payload = {}, options = {}, &block) ⇒ Object
- #handle_result(status, result) ⇒ Object
-
#initialize(sid) {|@config| ... } ⇒ Client
constructor
A new instance of Client.
- #method_missing(method, payload = {}, options = {}, &block) ⇒ Object
Constructor Details
#initialize(sid) {|@config| ... } ⇒ Client
Returns a new instance of Client.
12 13 14 15 |
# File 'lib/sub_zero/client.rb', line 12 def initialize sid @sid, @config = sid.to_s.upcase, Configuration.default yield @config if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, payload = {}, options = {}, &block) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sub_zero/client.rb', line 32 def method_missing method, payload = {}, = {}, &block if method.to_s.end_with? '!' call! method.delete('!'), payload, , &block else call method, payload, , &block end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/sub_zero/client.rb', line 10 def config @config end |
#sid ⇒ Object (readonly)
Returns the value of attribute sid.
10 11 12 |
# File 'lib/sub_zero/client.rb', line 10 def sid @sid end |
Instance Method Details
#[](verb) ⇒ Object
28 29 30 |
# File 'lib/sub_zero/client.rb', line 28 def [] verb call verb end |
#call(verb, payload = {}, options = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sub_zero/client.rb', line 17 def call verb, payload = {}, = {} sz_verb = verb.to_s.upcase.gsub('_', '/') status, result = zeromq_fetch(sz_verb, payload, ) result = handle_result(status, result) block_given? ? yield(result) : result end |
#call!(verb, payload = {}, options = {}, &block) ⇒ Object
24 25 26 |
# File 'lib/sub_zero/client.rb', line 24 def call! verb, payload = {}, = {}, &block call verb, payload, , &block end |