Class: WCC::Contentful::Events

Inherits:
Object
  • Object
show all
Includes:
Wisper::Publisher
Defined in:
lib/wcc/contentful/events.rb

Overview

WCC::Contentful::Events is a singleton which rebroadcasts Contentful update events. You can subscribe to these events in your initializer using the [wisper gem syntax](github.com/krisleech/wisper). All published events are in the namespace WCC::Contentful::Event.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEvents

Returns a new instance of Events.



17
18
19
# File 'lib/wcc/contentful/events.rb', line 17

def initialize
  _attach_listeners
end

Class Method Details

.instanceObject



13
14
15
# File 'lib/wcc/contentful/events.rb', line 13

def self.instance
  @instance ||= new
end

Instance Method Details

#rebroadcast(event) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
26
# File 'lib/wcc/contentful/events.rb', line 21

def rebroadcast(event)
  type = event.dig('sys', 'type')
  raise ArgumentError, "Unknown event type #{event}" unless type.present?

  broadcast(type, event)
end