Class: WCC::Contentful::Event::Registry
- Inherits:
-
Object
- Object
- WCC::Contentful::Event::Registry
- Includes:
- Singleton
- Defined in:
- lib/wcc/contentful/event.rb
Instance Method Summary collapse
Instance Method Details
#get(name) ⇒ Object
19 20 21 22 |
# File 'lib/wcc/contentful/event.rb', line 19 def get(name) @event_types ||= {} @event_types[name] || WCC::Contentful::Event::Unknown end |
#register(constant) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/wcc/contentful/event.rb', line 24 def register(constant) name = constant.try(:type) || constant.name.demodulize raise ArgumentError, "Constant #{constant} does not define 'new'" unless constant.respond_to?(:new) @event_types ||= {} @event_types[name] = constant end |