Class: ConfigManager::Item

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

Overview

Class Item. Manager an item save with his type, the default value and his name

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



73
74
75
# File 'lib/config_manager.rb', line 73

def default
  @default
end

#nameObject

Returns the value of attribute name.



73
74
75
# File 'lib/config_manager.rb', line 73

def name
  @name
end

#ruby_typeObject

Returns the value of attribute ruby_type.



73
74
75
# File 'lib/config_manager.rb', line 73

def ruby_type
  @ruby_type
end

Instance Method Details

#canonicalize(value) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/config_manager.rb', line 75

def canonicalize(value)
  case ruby_type
  when :boolean
    case value
    when "0", 0, '', false, "false", "f", nil
      false
    else
      true
    end
  when :integer
    value.to_i
  when :string
    value.to_s
  when :yaml
    value.to_yaml
  else
    value
  end
end