Class: ConfigManager::Setting

Inherits:
Object
  • Object
show all
Includes:
ConfigManager::Settings::Persistence, ConfigManager::Settings::Querying, ConfigManager::Settings::Values, ConfigManager::Settings::Yaml
Defined in:
lib/config_manager/setting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigManager::Settings::Yaml

included

Methods included from ConfigManager::Settings::Values

included

Methods included from ConfigManager::Settings::Querying

included

Methods included from ConfigManager::Settings::Persistence

included, #persist

Constructor Details

#initialize(id, value, tags) ⇒ Setting

Returns a new instance of Setting.



10
11
12
13
14
# File 'lib/config_manager/setting.rb', line 10

def initialize(id, value, tags)
	@id = id
	@value = value
	@tags = tags
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/config_manager/setting.rb', line 8

def id
  @id
end

#tagsObject (readonly)

Returns the value of attribute tags.



8
9
10
# File 'lib/config_manager/setting.rb', line 8

def tags
  @tags
end

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/config_manager/setting.rb', line 8

def value
  @value
end

Instance Method Details

#formatted_tagsObject



20
21
22
# File 'lib/config_manager/setting.rb', line 20

def formatted_tags
	@tags && @tags.join(', ')
end

#messageObject



24
25
26
27
# File 'lib/config_manager/setting.rb', line 24

def message
	return "missing name(id)" unless @id.present?
	return "missing value" unless !!@value
end

#to_hashObject



29
30
31
# File 'lib/config_manager/setting.rb', line 29

def to_hash
	{'id' => id, 'value' => value, 'tags' => formatted_tags}
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/config_manager/setting.rb', line 16

def valid?
	@id.present? && !!@value
end