Class: FakeSQS::API
- Inherits:
-
Object
- Object
- FakeSQS::API
- Defined in:
- lib/fake_sqs/api.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
Instance Method Summary collapse
- #call(action, *args) ⇒ Object
- #expire ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
-
#reset ⇒ Object
Fake actions.
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ API
Returns a new instance of API.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fake_sqs/api.rb', line 22 def initialize( = {}) @queues = .fetch(:queues) @options = @run_timer = true @timer = Thread.new do while @run_timer queues. sleep(5) end end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/fake_sqs/api.rb', line 20 def @options end |
#queues ⇒ Object (readonly)
Returns the value of attribute queues.
20 21 22 |
# File 'lib/fake_sqs/api.rb', line 20 def queues @queues end |
Instance Method Details
#call(action, *args) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fake_sqs/api.rb', line 34 def call(action, *args) if FakeSQS::Actions.const_defined?(action) action = FakeSQS::Actions.const_get(action).new() queues.transaction do action.call(*args) end else fail InvalidAction, "Unknown (or not yet implemented) action: #{action}" end end |
#expire ⇒ Object
51 52 53 |
# File 'lib/fake_sqs/api.rb', line 51 def expire queues.expire end |
#reset ⇒ Object
Fake actions
47 48 49 |
# File 'lib/fake_sqs/api.rb', line 47 def reset queues.reset end |
#stop ⇒ Object
55 56 57 |
# File 'lib/fake_sqs/api.rb', line 55 def stop @run_timer = false end |