Module: Rucola::Notifications

Defined in:
lib/rucola/rucola_support/notifications/notifications.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc



164
165
166
167
168
169
170
171
172
# File 'lib/rucola/rucola_support/notifications/notifications.rb', line 164

def self.included(base) # :nodoc
  base.extend(ClassMethods)
  
  # register the initialize hook which actually registers the notifications for the instance.
  base._rucola_register_initialize_hook lambda { self._register_notifications }
  
  # register default shortcut
  base.notification_prefix :app => :application
end

Instance Method Details

#_register_notificationsObject

this instance method is called after object initialization by the initialize hook



175
176
177
178
179
180
181
182
# File 'lib/rucola/rucola_support/notifications/notifications.rb', line 175

def _register_notifications # :nodoc:
  notifications = self.class.instance_variable_get(:@_registered_notifications)
  return if notifications.nil?
  center = OSX::NSNotificationCenter.defaultCenter
  notifications.each do |notification_name, notification_handler|
    center.addObserver_selector_name_object(self, notification_handler, notification_name, nil)
  end
end