Class: CoreMerchant::SubscriptionEvent

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/core_merchant/subscription_event.rb

Overview

# Retrieve the last event of any type latest_event = subscription.subscription_events.last puts “Last event type: #latest_eventlatest_event.event_type, metadata: #latest_eventlatest_event.metadata” “‘

Instance Method Summary collapse

Instance Method Details

#metadataObject



40
41
42
43
# File 'lib/core_merchant/subscription_event.rb', line 40

def 
  value = self[:metadata]
  value.is_a?(Hash) ? value : JSON.parse(value || "{}")
end

#metadata=(value) ⇒ Object



45
46
47
# File 'lib/core_merchant/subscription_event.rb', line 45

def metadata=(value)
  self[:metadata] = value.is_a?(Hash) ? value.to_json : value
end