Class: ConfigManager::Item

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

Constant Summary collapse

VALID_TYPES =
[:boolean, :integer, :string, :text].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



71
72
73
# File 'app/models/config_manager.rb', line 71

def default
  @default
end

#nameObject

Returns the value of attribute name.



71
72
73
# File 'app/models/config_manager.rb', line 71

def name
  @name
end

#ruby_typeObject

Returns the value of attribute ruby_type.



71
72
73
# File 'app/models/config_manager.rb', line 71

def ruby_type
  @ruby_type
end

Instance Method Details

#canonicalize(value) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'app/models/config_manager.rb', line 73

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, :text
    value.to_s
  end
end