Class: Utopia::Content::SymbolicHash
- Inherits:
-
Hash
- Object
- Hash
- Utopia::Content::SymbolicHash
- 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
-
#[](key) ⇒ Object
-
#[]=(key, value) ⇒ Object
-
#fetch(key, *args, &block) ⇒ Object
-
#include?(key) ⇒ Boolean
Instance Method Details
#[](key) ⇒ Object
32 33 34 35 |
# File 'lib/utopia/content/markup.rb', line 32 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
37 38 39 |
# File 'lib/utopia/content/markup.rb', line 37 def []= key, value super key.to_sym, value end |
#fetch(key, *args, &block) ⇒ Object
41 42 43 44 45 |
# File 'lib/utopia/content/markup.rb', line 41 def fetch(key, *args, &block) key = key.to_sym super end |
#include?(key) ⇒ Boolean
47 48 49 50 51 |
# File 'lib/utopia/content/markup.rb', line 47 def include? key key = key.to_sym super end |