Module: Bowline::Watcher::Base

Included in:
Binders::Base, Desktop, Desktop::Network, Desktop::WindowManager
Defined in:
lib/bowline/watcher.rb

Overview

Callbacks on steroids. Add callbacks as class methods, or instance ones.

class MyClass

extend Bowline::Watcher::Base
watch :update, :create

def self.update
  watcher.call(:update)
end

def create
  watcher.call(:create)
end

end

MyClass.on_update { puts 'update' } MyClass.new.on_create { puts 'create' }

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) extended(base)



22
23
24
# File 'lib/bowline/watcher.rb', line 22

def self.extended(base)
	base.send :extend, ClassMethods
end

+ (Object) included(base)



26
27
28
# File 'lib/bowline/watcher.rb', line 26

def self.included(base)
  base.send :extend, InstanceMethods
end

Instance Method Details

- (Object) watcher



30
31
32
# File 'lib/bowline/watcher.rb', line 30

def watcher
  @watcher ||= Watcher.new
end