Class: ConvenientService::Support::DependencyContainer::Entities::NamespaceCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/support/dependency_container/entities/namespace_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(namespaces: []) ⇒ void

Parameters:



17
18
19
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 17

def initialize(namespaces: [])
  @namespaces = namespaces
end

Instance Method Details

#<<(namespace) ⇒ ConvenientService::Support::DependencyContainer::Entities::NamespaceCollection



39
40
41
42
43
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 39

def <<(namespace)
  namespaces << namespace

  self
end

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


80
81
82
83
84
85
86
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 80

def ==(other)
  return unless other.instance_of?(self.class)

  return false if namespaces != other.namespaces

  true
end

#clearConvenientService::Support::DependencyContainer::Entities::NamespaceCollection



63
64
65
66
67
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 63

def clear
  namespaces.clear

  self
end

#empty?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 48

def empty?
  namespaces.empty?
end

#find_by(name: Support::NOT_PASSED) ⇒ ConvenientService::Support::DependencyContainer::Entities::Namespace?

Parameters:

  • name (String, Symbol) (defaults to: Support::NOT_PASSED)

Returns:



25
26
27
28
29
30
31
32
33
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 25

def find_by(name: Support::NOT_PASSED)
  rules = []

  rules << ->(namespace) { namespace.name.to_s == name.to_s } unless Support::NOT_PASSED[name]

  condition = Utils::Proc.conjunct(rules)

  namespaces.find(&condition)
end

#include?(namespace) ⇒ Boolean



56
57
58
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 56

def include?(namespace)
  namespaces.include?(namespace)
end

#to_aArray

Returns:

  • (Array)


72
73
74
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 72

def to_a
  namespaces.to_a
end