Class: NamespaceCache
- Inherits:
-
Object
- Object
- NamespaceCache
- Defined in:
- lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb
Instance Attribute Summary collapse
-
#namespace_cache ⇒ Object
Returns the value of attribute namespace_cache.
Class Method Summary collapse
Instance Method Summary collapse
- #cache_namespace(namespace_regex) ⇒ Object
- #clear_cache ⇒ Object
- #get_cached_namespaces ⇒ Object
-
#initialize ⇒ NamespaceCache
constructor
A new instance of NamespaceCache.
- #is_namespace_cache_empty? ⇒ Boolean
- #is_type_allowed(type_to_check) ⇒ Object
Constructor Details
#initialize ⇒ NamespaceCache
Returns a new instance of NamespaceCache.
10 11 12 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 10 def initialize @namespace_cache = [] end |
Instance Attribute Details
#namespace_cache ⇒ Object
Returns the value of attribute namespace_cache.
2 3 4 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 2 def namespace_cache @namespace_cache end |
Class Method Details
.instance ⇒ Object
4 5 6 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 4 def self.instance @instance ||= new end |
Instance Method Details
#cache_namespace(namespace_regex) ⇒ Object
14 15 16 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 14 def cache_namespace(namespace_regex) @namespace_cache << namespace_regex end |
#clear_cache ⇒ Object
38 39 40 41 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 38 def clear_cache @namespace_cache.clear 0 end |
#get_cached_namespaces ⇒ Object
34 35 36 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 34 def get_cached_namespaces @namespace_cache end |
#is_namespace_cache_empty? ⇒ Boolean
18 19 20 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 18 def is_namespace_cache_empty? @namespace_cache.empty? end |
#is_type_allowed(type_to_check) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/javonet-ruby-sdk/core/namespace_cache/namespace_cache.rb', line 22 def is_type_allowed(type_to_check) name_to_check = if type_to_check.is_a?(Module) type_to_check.name else "#{type_to_check.class.name}" end @namespace_cache.any? do |pattern| /#{pattern}/.match?(name_to_check) end end |