Class: SmartCore::Container::Host Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/container/host.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.1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, 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.

Parameters:

Since:

  • 0.8.1



63
64
65
66
67
# File 'lib/smart_core/container/host.rb', line 63

def initialize(container, path)
  @container = container
  @path = path
  @exists = !!container
end

Instance Attribute Details

#containerSmartCore::Container (readonly)

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.

Returns:

Since:

  • 0.8.1



41
42
43
# File 'lib/smart_core/container/host.rb', line 41

def container
  @container
end

#existsBoolean (readonly) Also known as: exists?, present?

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.

Returns:

  • (Boolean)

Since:

  • 0.8.1



53
54
55
# File 'lib/smart_core/container/host.rb', line 53

def exists
  @exists
end

#pathString (readonly)

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.

Returns:

  • (String)

Since:

  • 0.8.1



47
48
49
# File 'lib/smart_core/container/host.rb', line 47

def path
  @path
end

Class Method Details

.build(container, path) ⇒ SmartCore::Container::Host

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.

rubocop:disable Metrics/AbcSize, Style/NilComparison

Parameters:

Returns:

Since:

  • 0.8.1



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/smart_core/container/host.rb', line 16

def build(container, path)
  if (container.nil? && !path.nil?) || (!container.nil? && path.nil?)
    raise(SmartCore::Container::ArgumentError, <<~ERROR_MESSAGE)
      Host container requires both host container instance and host container path
      (container: #{container.inspect} / path: #{path.inspect})
    ERROR_MESSAGE
  end

  if (!container.nil? && !path.nil?) &&
     (!container.is_a?(SmartCore::Container) || !path.is_a?(String))
    raise(SmartCore::Container::ArgumentError, <<~ERROR_MESSAGE)
      Host container should be a type of SmartCore::Container
      and host path should be a type of String.
    ERROR_MESSAGE
  end

  new(container, path)
end

Instance Method Details

#notify_about_nested_changement(nested_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:

  • nested_entity_path (String)

Since:

  • 0.8.1



74
75
76
77
78
79
80
# File 'lib/smart_core/container/host.rb', line 74

def notify_about_nested_changement(nested_entity_path)
  return unless exists?
  host_path = "#{path}" \
              "#{SmartCore::Container::DependencyResolver::PATH_PART_SEPARATOR}" \
              "#{nested_entity_path}"
  container.watcher.notify(host_path)
end