Class: VcrStripeWebhook::EventCassette
- Inherits:
-
Object
- Object
- VcrStripeWebhook::EventCassette
- Defined in:
- lib/vcr_stripe_webhook/event_cassette.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#vcr_cassette ⇒ Object
readonly
Returns the value of attribute vcr_cassette.
Instance Method Summary collapse
-
#initialize(name, vcr_cassette, recording) ⇒ EventCassette
constructor
A new instance of EventCassette.
- #path ⇒ Object
- #receive_event_payload(event) ⇒ Object
- #recording? ⇒ Boolean
- #serialize ⇒ Object
- #wait_for_events(waiter, timeout:, &block) ⇒ Object
Constructor Details
#initialize(name, vcr_cassette, recording) ⇒ EventCassette
Returns a new instance of EventCassette.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 12 def initialize(name, vcr_cassette, recording) @mutex = Mutex.new @name = name @vcr_cassette = vcr_cassette @recording = recording if recording @data = Data.new else @data = Data.deserialize(path) @wait_counter = 0 end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 10 def name @name end |
#vcr_cassette ⇒ Object (readonly)
Returns the value of attribute vcr_cassette.
10 11 12 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 10 def vcr_cassette @vcr_cassette end |
Instance Method Details
#path ⇒ Object
25 26 27 28 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 25 def path dir = VcrStripeWebhook.configuration.cassette_library_dir File.join(dir, "#{name}.stripe_webhooks.yml") end |
#receive_event_payload(event) ⇒ Object
42 43 44 45 46 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 42 def receive_event_payload(event) @mutex.synchronize do @data.events.push(event) end end |
#recording? ⇒ Boolean
30 31 32 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 30 def recording? @recording end |
#serialize ⇒ Object
48 49 50 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 48 def serialize @data.serialize(path) end |
#wait_for_events(waiter, timeout:, &block) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 34 def wait_for_events(waiter, timeout:, &block) if recording? record_and_wait_for_events(waiter, timeout: timeout, &block) else replay_and_wait_for_events(waiter, &block) end end |