class Tomlrb::Key
Attributes
Public Class Methods
Source
# File lib/tomlrb/handler.rb, line 173 def initialize(key, type, declared = false) @key = key @type = type @declared = declared @children = {} end
Public Instance Methods
Source
# File lib/tomlrb/handler.rb, line 184 def <<(key_type_declared) key, type, declared, is_array_of_tables = key_type_declared existed = @children[key] validate_already_declared_as_different_key(type, declared, existed) validate_already_declared_as_non_array_table(type, is_array_of_tables, declared, existed) validate_path_already_created_as_different_type(type, declared, existed) validate_path_already_declared_as_different_type(type, declared, existed) validate_already_declared_as_same_key(declared, existed) @children[key] = existed || self.class.new(key, type, declared) end
Source
# File lib/tomlrb/handler.rb, line 195 def clear_children @children.clear end
Private Instance Methods
Source
# File lib/tomlrb/handler.rb, line 201 def validate_already_declared_as_different_key(type, declared, existed) if declared && existed && existed.declared? && existed.type != type raise KeyConflict, "Key #{existed.key} is already used as #{existed.type} key" end end
Source
# File lib/tomlrb/handler.rb, line 207 def validate_already_declared_as_non_array_table(type, is_array_of_tables, declared, existed) if declared && type == :table && existed && existed.declared? && ! is_array_of_tables raise KeyConflict, "Key #{existed.key} is already used" end end
Source
# File lib/tomlrb/handler.rb, line 225 def validate_already_declared_as_same_key(declared, existed) if existed && ! existed.declared? && declared raise KeyConflict, "Key #{existed.key} is already used as #{existed.type} key" end end
Source
# File lib/tomlrb/handler.rb, line 213 def validate_path_already_created_as_different_type(type, declared, existed) if declared && (type == :table) && existed && (existed.type == :pair) && (! existed.declared?) raise KeyConflict, "Key #{existed.key} is already used as #{existed.type} key" end end
Source
# File lib/tomlrb/handler.rb, line 219 def validate_path_already_declared_as_different_type(type, declared, existed) if ! declared && (type == :pair) && existed && (existed.type == :pair) && existed.declared? raise KeyConflict, "Key #{key} is already used as #{type} key" end end