Class: KManager::Area
- Inherits:
-
Object
- Object
- KManager::Area
- Extended by:
- Forwardable
- Includes:
- KLog::Logging
- Defined in:
- lib/k_manager/area.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#name ⇒ Object
readonly
TODO: I have not got a use for area name yet, it may be able to drive default config, but not sure.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#attribute_values(prefix = nil) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #debug(*sections) ⇒ Object
-
#initialize(**opts) ⇒ Area
constructor
A new instance of Area.
- #resource_manager ⇒ Object
Constructor Details
#initialize(**opts) ⇒ Area
Returns a new instance of Area.
14 15 16 17 18 19 20 21 22 |
# File 'lib/k_manager/area.rb', line 14 def initialize(**opts) @manager = opts[:manager] @name = opts[:name] raise 'Area name is required' unless @name @namespace = opts[:namespace] || @name @config = KConfig.configuration(@name) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/k_manager/area.rb', line 12 def config @config end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
8 9 10 |
# File 'lib/k_manager/area.rb', line 8 def manager @manager end |
#name ⇒ Object (readonly)
TODO: I have not got a use for area name yet, it may be able to drive default config, but not sure.
10 11 12 |
# File 'lib/k_manager/area.rb', line 10 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/k_manager/area.rb', line 11 def namespace @namespace end |
Instance Method Details
#attribute_values(prefix = nil) ⇒ Object
rubocop:disable Metrics/AbcSize
39 40 41 42 43 44 45 46 |
# File 'lib/k_manager/area.rb', line 39 def attribute_values(prefix = nil) result = {} result["#{prefix}name".to_sym] = name result["#{prefix}namespace".to_sym] = namespace result["#{prefix}resource_count".to_sym] = resource_manager.resources.length result["#{prefix}document_count".to_sym] = resource_manager.resources.sum { |resource| resource.documents.length } result end |
#debug(*sections) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/k_manager/area.rb', line 30 def debug(*sections) log.kv 'Area' , name log.kv 'Namespace' , namespace resource_manager.debug if sections.include?(:resource) || sections.include?(:resources) config.debug if sections.include?(:config) end |
#resource_manager ⇒ Object
24 25 26 |
# File 'lib/k_manager/area.rb', line 24 def resource_manager @resource_manager ||= KManager::Resources::ResourceManager.new(self) end |