Module: Hippo::Concerns::PubSub::ClassMethods
- Defined in:
- lib/hippo/concerns/pub_sub.rb
Instance Method Summary collapse
Instance Method Details
#inherited(base) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/hippo/concerns/pub_sub.rb', line 60 def inherited(base) super klass = base.to_s.demodulize events = PubSub::PendingListeners.claim( klass ) events.each{ | name, procs | procs.each{|pr| base.send(:_add_event_listener, name, &pr) } } end |
#observe(event, &block) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/hippo/concerns/pub_sub.rb', line 71 def observe( event, &block ) unless self.valid_event_names.include?(event.to_sym) raise InvalidEvent.new("#{event} is not a valid event for #{self}") end _add_event_listener( event.to_sym, &block ) end |