Class: TivoHMO::Adapters::Settings::KeyContainer

Inherits:
Object
  • Object
show all
Includes:
GemLogger::LoggerSupport, MonitorMixin, TivoHMO::API::Container
Defined in:
lib/tivohmo/adapters/settings/key_container.rb

Overview

A Container for config keys

Instance Attribute Summary

Attributes included from TivoHMO::API::Container

#presorted, #uuid

Attributes included from TivoHMO::API::Node

#app, #content_type, #created_at, #identifier, #modified_at, #parent, #root, #source_format, #title

Instance Method Summary collapse

Methods included from TivoHMO::API::Container

#child_count, #refresh

Methods included from TivoHMO::API::Node

#add_child, #app?, #find, #root?, #title_path, #to_s, #tree_string

Constructor Details

#initialize(key) ⇒ KeyContainer

Returns a new instance of KeyContainer.



11
12
13
14
# File 'lib/tivohmo/adapters/settings/key_container.rb', line 11

def initialize(key)
  super(key)
  self.presorted = true
end

Instance Method Details

#childrenObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tivohmo/adapters/settings/key_container.rb', line 16

def children
  synchronize do
    if super.blank?
      spec = Config.instance.known_config[identifier]
      add_child(DisplayItem.new("Help", spec[:description]))
      add_child(DisplayItem.new("Default Value: #{spec[:default_value]}"))
      val = Config.instance.get(identifier)
      add_child(DisplayItem.new("Current Value: #{!!val}"))
      add_child(SetValueItem.new(identifier, !val))
    end
  end

  super
end