Module: FastlyNsq::ProducerTesting
- Included in:
- Producer
- Defined in:
- lib/fastly_nsq/testing.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #connected? ⇒ Boolean
- #connection ⇒ Object
- #messages ⇒ Object
- #terminate ⇒ Object
- #write(message) ⇒ Object
Instance Method Details
#connect ⇒ Object
180 181 182 183 |
# File 'lib/fastly_nsq/testing.rb', line 180 def connect return super unless FastlyNsq::Testing.enabled? @connected = true end |
#connected? ⇒ Boolean
145 146 147 148 149 |
# File 'lib/fastly_nsq/testing.rb', line 145 def connected? return super unless FastlyNsq::Testing.enabled? @connected = true if @connected.nil? @connected end |
#connection ⇒ Object
174 175 176 177 178 |
# File 'lib/fastly_nsq/testing.rb', line 174 def connection return super unless FastlyNsq::Testing.enabled? return nil unless connected? self end |
#messages ⇒ Object
185 186 187 188 189 |
# File 'lib/fastly_nsq/testing.rb', line 185 def raise NoMethodError unless FastlyNsq::Testing.enabled? FastlyNsq::Messages.[topic] end |
#terminate ⇒ Object
151 152 153 154 155 |
# File 'lib/fastly_nsq/testing.rb', line 151 def terminate return super unless FastlyNsq::Testing.enabled? @connected = false end |
#write(message) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/fastly_nsq/testing.rb', line 157 def write() return super unless FastlyNsq::Testing.enabled? raise FastlyNsq::NotConnectedError unless connected? = TestMessage.new() FastlyNsq::Messages.[topic] << if FastlyNsq::Testing.inline? listener = FastlyNsq.manager.topic_listeners[topic] return unless listener listener.call end true end |