Class: NamespaceCache
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/namespace_cache/namespace_cache.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/namespace_cache/namespace_cache.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/namespace_cache/namespace_cache.rb
Constant Summary
Constants included
from Singleton
Singleton::VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Singleton
__init__, #_dump, #clone, #dup
Constructor Details
Returns a new instance of NamespaceCache.
8
9
10
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 8
def initialize
@namespace_cache = []
end
|
Instance Attribute Details
#namespace_cache ⇒ Object
Returns the value of attribute namespace_cache.
6
7
8
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 6
def namespace_cache
@namespace_cache
end
|
Instance Method Details
#cache_namespace(namespace_regex) ⇒ Object
12
13
14
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 12
def cache_namespace(namespace_regex)
@namespace_cache << namespace_regex
end
|
#clear_cache ⇒ Object
36
37
38
39
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 36
def clear_cache
@namespace_cache.clear
0
end
|
#get_cached_namespaces ⇒ Object
32
33
34
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 32
def get_cached_namespaces
@namespace_cache
end
|
#is_namespace_cache_empty? ⇒ Boolean
16
17
18
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 16
def is_namespace_cache_empty?
@namespace_cache.empty?
end
|
#is_type_allowed(type_to_check) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 20
def is_type_allowed(type_to_check)
if type_to_check.is_a?(Module)
name_to_check = type_to_check.name
else
name_to_check = "#{type_to_check.class.name}"
end
@namespace_cache.any? do |pattern|
/#{pattern}/.match?(name_to_check)
end
end
|