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:



12
13
14
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 12

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

Instance Method Details

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



34
35
36
37
38
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 34

def <<(namespace)
  namespaces << namespace

  self
end

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean)


75
76
77
78
79
80
81
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 75

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

  return false if namespaces != other.namespaces

  true
end

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



58
59
60
61
62
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 58

def clear
  namespaces.clear

  self
end

#empty?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 43

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:



20
21
22
23
24
25
26
27
28
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 20

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

  rules << ->(namespace) { namespace.name.to_s == name.to_s } if name != Support::NOT_PASSED

  condition = Utils::Proc.conjunct(rules)

  namespaces.find(&condition)
end

#include?(namespace) ⇒ Boolean



51
52
53
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 51

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

#to_aArray

Returns:

  • (Array)


67
68
69
# File 'lib/convenient_service/support/dependency_container/entities/namespace_collection.rb', line 67

def to_a
  namespaces.to_a
end