Class: Utopia::Content::SymbolicHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/utopia/content/markup.rb

Overview

A hash which forces all keys to be symbols and fails with KeyError when strings are used.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Raises:

  • (KeyError)


34
35
36
37
# File 'lib/utopia/content/markup.rb', line 34

def [] key
	raise KeyError.new("attribute #{key} is a string, prefer a symbol") if key.is_a? String
	super key.to_sym
end

#[]=(key, value) ⇒ Object



39
40
41
# File 'lib/utopia/content/markup.rb', line 39

def []= key, value
	super key.to_sym, value
end

#fetch(key, *arguments, &block) ⇒ Object



43
44
45
46
47
# File 'lib/utopia/content/markup.rb', line 43

def fetch(key, *arguments, &block)
	key = key.to_sym
	
	super
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/utopia/content/markup.rb', line 49

def include? key
	key = key.to_sym
	
	super
end