Class: GripPubControl
- Inherits:
-
PubControl
- Object
- PubControl
- GripPubControl
- Defined in:
- lib/grippubcontrol.rb
Instance Method Summary collapse
- #apply_grip_config(config) ⇒ Object
-
#initialize(config = nil) ⇒ GripPubControl
constructor
A new instance of GripPubControl.
- #publish_http_response(channel, http_response, id = nil, prev_id = nil) ⇒ Object
- #publish_http_response_async(channel, http_response, id = nil, prev_id = nil, callback = nil) ⇒ Object
- #publish_http_stream(channel, http_stream, id = nil, prev_id = nil) ⇒ Object
- #publish_http_stream_async(channel, http_stream, id = nil, prev_id = nil, callback = nil) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ GripPubControl
Returns a new instance of GripPubControl.
15 16 17 18 19 20 |
# File 'lib/grippubcontrol.rb', line 15 def initialize(config=nil) @clients = Array.new if !config.nil? apply_grip_config(config) end end |
Instance Method Details
#apply_grip_config(config) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/grippubcontrol.rb', line 22 def apply_grip_config(config) if !config.is_a?(Array) config = [config] end config.each do |entry| if !entry.key?('control_uri') next end client = PubControlClient.new(entry['control_uri']) if entry.key?('control_iss') client.set_auth_jwt({'iss' => entry['control_iss']}, entry['key']) end super_add_client(client) end end |
#publish_http_response(channel, http_response, id = nil, prev_id = nil) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/grippubcontrol.rb', line 38 def publish_http_response(channel, http_response, id=nil, prev_id=nil) if http_response.is_a?(String) http_response = HttpResponseFormat.new(nil, nil, nil, http_response) end item = Item.new(http_response, id, prev_id) super_publish(channel, item) end |
#publish_http_response_async(channel, http_response, id = nil, prev_id = nil, callback = nil) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/grippubcontrol.rb', line 46 def publish_http_response_async(channel, http_response, id=nil, prev_id=nil, callback=nil) if http_response.is_a?(String) http_response = HttpResponseFormat.new(nil, nil, nil, http_response) end item = Item.new(http_response, id, prev_id) super_publish_async(channel, item, callback) end |
#publish_http_stream(channel, http_stream, id = nil, prev_id = nil) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/grippubcontrol.rb', line 55 def publish_http_stream(channel, http_stream, id=nil, prev_id=nil) if http_stream.is_a?(String) http_stream = HttpStreamFormat.new(http_stream) end item = Item.new(http_stream, id, prev_id) super_publish(channel, item) end |
#publish_http_stream_async(channel, http_stream, id = nil, prev_id = nil, callback = nil) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/grippubcontrol.rb', line 63 def publish_http_stream_async(channel, http_stream, id=nil, prev_id=nil, callback=nil) if http_stream.is_a?(String) http_stream = HttpStreamFormat.new(http_stream) end item = Item.new(http_stream, id, prev_id) super_publish_async(channel, item, callback) end |