Class: VcrStripeWebhook::EventCassette::Data
- Inherits:
-
Object
- Object
- VcrStripeWebhook::EventCassette::Data
- Defined in:
- lib/vcr_stripe_webhook/event_cassette.rb
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#waits ⇒ Object
readonly
Returns the value of attribute waits.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(events: [], waits: []) ⇒ Data
constructor
A new instance of Data.
- #serialize(path) ⇒ Object
Constructor Details
#initialize(events: [], waits: []) ⇒ Data
Returns a new instance of Data.
132 133 134 135 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 132 def initialize(events: [], waits: []) @events = events @waits = waits end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
130 131 132 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 130 def events @events end |
#waits ⇒ Object (readonly)
Returns the value of attribute waits.
130 131 132 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 130 def waits @waits end |
Class Method Details
.deserialize(path) ⇒ Object
147 148 149 150 151 152 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 147 def deserialize(path) yaml = YAML.safe_load_file(path, permitted_classes: []) events = yaml["events"].map { |event_hash| Event.from_hash(event_hash) } waits = yaml["waits"].map { |hash| Wait.from_hash(hash) } Data.new(events: events, waits: waits) end |
Instance Method Details
#serialize(path) ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'lib/vcr_stripe_webhook/event_cassette.rb', line 137 def serialize(path) yaml = YAML.dump({ "events" => @events.map(&:to_h), "waits" => @waits.map(&:to_h) }) FileUtils.mkdir_p File.dirname(path) File.write(path, yaml) end |