Class: WCC::Contentful::Events
- Inherits:
-
Object
- Object
- WCC::Contentful::Events
- 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
-
#initialize ⇒ Events
constructor
A new instance of Events.
- #rebroadcast(event) ⇒ Object
Constructor Details
#initialize ⇒ Events
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
.instance ⇒ Object
13 14 15 |
# File 'lib/wcc/contentful/events.rb', line 13 def self.instance @instance ||= new end |
Instance Method Details
#rebroadcast(event) ⇒ Object
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 |