Class: LazyGraph::ObjectNode::SymbolHash
- Inherits:
-
Hash
- Object
- Hash
- LazyGraph::ObjectNode::SymbolHash
show all
- Defined in:
- lib/lazy_graph/node/symbol_hash.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SymbolHash.
[View source]
4
5
6
7
8
|
# File 'lib/lazy_graph/node/symbol_hash.rb', line 4
def initialize(input_hash = {})
super
merge!(input_hash.transform_keys(&:to_sym))
compare_by_identity
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
permalink
#method_missing(name, *args, &block) ⇒ Object
[View source]
26
27
28
29
30
31
32
|
# File 'lib/lazy_graph/node/symbol_hash.rb', line 26
def method_missing(name, *args, &block)
if key?(name)
self[name]
else
super
end
end
|
Instance Method Details
[View source]
18
19
20
21
22
23
24
|
# File 'lib/lazy_graph/node/symbol_hash.rb', line 18
def [](key)
case key
when Symbol then super(key)
when String then super(key.to_sym)
else super(key.to_s.to_sym)
end
end
|
permalink
#[]=(key, value) ⇒ Object
[View source]
10
11
12
13
14
15
16
|
# File 'lib/lazy_graph/node/symbol_hash.rb', line 10
def []=(key, value)
case key
when Symbol then super(key, value)
when String then super(key.to_sym, value)
else super(key.to_s.to_sym, value)
end
end
|
permalink
#respond_to_missing?(name, include_private = false) ⇒ Boolean
[View source]
34
35
36
|
# File 'lib/lazy_graph/node/symbol_hash.rb', line 34
def respond_to_missing?(name, include_private = false)
key?(name) || super
end
|