Class: PublishToWeb::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/publish_to_web/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store: SKVS) ⇒ Config

Returns a new instance of Config.



20
21
22
# File 'lib/publish_to_web/config.rb', line 20

def initialize(store: SKVS)
  @store = store
end

Class Method Details

.config_attribute(name, key) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/publish_to_web/config.rb', line 6

def self.config_attribute(name, key)
  define_method name do
    store.get key
  end

  define_method "#{name}=" do |value|
    if value.nil?
      store.del key
    else
      store.set key, value
    end
  end
end

Instance Method Details

#active_accountsObject



43
44
45
# File 'lib/publish_to_web/config.rb', line 43

def active_accounts
  store.get 'soul/active_accounts'
end

#enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/publish_to_web/config.rb', line 24

def enabled?
  !!store.get('ptw/control/enabled')
end

#support_identifierObject



47
48
49
50
51
52
# File 'lib/publish_to_web/config.rb', line 47

def support_identifier
  identifier = store.get('system/support_identifier')
  if identifier.kind_of?(String) and identifier.strip.length > 0
    identifier
  end
end

#system_versionObject



54
55
56
57
58
59
60
61
# File 'lib/publish_to_web/config.rb', line 54

def system_version
  parts = [store.get('system/channel'), store.get('system/release_number')]
  if parts.all? {|p| p.kind_of?(String) and p.strip.length > 0 }
    parts.join("/")
  else
    "unknown"
  end
end