Class: SmartCore::Container::DependencyWatcher Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/container/dependency_watcher.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.8.0

Version:

  • 0.11.0

Defined Under Namespace

Classes: Observer

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Since:

  • 0.8.0

Version:

  • 0.11.0



15
16
17
18
19
# File 'lib/smart_core/container/dependency_watcher.rb', line 15

def initialize(container)
  @container = container
  @observers = Hash.new { |h, k| h[k] = [] }
  @lock = SmartCore::Engine::ReadWriteLock.new
end

Instance Method Details

#clear_listeners(entity_path = nil) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • entity_path (String, Symbol, NilClass) (defaults to: nil)

Since:

  • 0.8.0

Version:

  • 0.11.0



58
59
60
# File 'lib/smart_core/container/dependency_watcher.rb', line 58

def clear_listeners(entity_path = nil) # TODO: support for pattern-based pathes
  @lock.write_sync { remove_listeners(entity_path) }
end

#notify(entity_path) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Parameters:

  • entity_path (String, Symbol)

Since:

  • 0.8.0

Version:

  • 0.11.0



27
28
29
# File 'lib/smart_core/container/dependency_watcher.rb', line 27

def notify(entity_path)
  @lock.read_sync { notify_listeners(entity_path) }
end

#unwatch(observer) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:

  • (Boolean)

Since:

  • 0.8.0

Version:

  • 0.11.0



48
49
50
# File 'lib/smart_core/container/dependency_watcher.rb', line 48

def unwatch(observer)
  @lock.write_sync { remove_listener(observer) }
end

#watch(entity_path, &observer) ⇒ SmartCore::Container::DependencyWatcher::Observer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • entity_path (String, Symbol)
  • observer (Block)

Returns:

Since:

  • 0.8.0

Version:

  • 0.11.0



38
39
40
# File 'lib/smart_core/container/dependency_watcher.rb', line 38

def watch(entity_path, &observer) # TODO: support for pattern-based pathes
  @lock.write_sync { listen(entity_path, observer) }
end