Class: Middleman::CoreExtensions::Data::Proxies::HashProxy
- Inherits:
-
BaseProxy
- Object
- BaseProxy
- Middleman::CoreExtensions::Data::Proxies::HashProxy
show all
- Defined in:
- middleman-core/lib/middleman-core/core_extensions/data/proxies/hash.rb
Instance Attribute Summary
Attributes inherited from BaseProxy
#accessed_keys, #depth
Instance Method Summary
collapse
Methods inherited from BaseProxy
#_replace_parent, #_top, #as_json, #initialize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args) ⇒ Object
23
24
25
26
27
28
29
|
# File 'middleman-core/lib/middleman-core/core_extensions/data/proxies/hash.rb', line 23
def method_missing(name, *_args)
return self[name] if @data.key?(name)
super
rescue NoMethodError
nil
end
|
Instance Method Details
#[](key) ⇒ Object
Also known as:
get
14
15
16
|
# File 'middleman-core/lib/middleman-core/core_extensions/data/proxies/hash.rb', line 14
def [](key)
wrap_data key.to_sym, @data[key]
end
|
#fetch(key, default = Undefined, &block) ⇒ Object
10
11
12
|
# File 'middleman-core/lib/middleman-core/core_extensions/data/proxies/hash.rb', line 10
def fetch(key, default = Undefined, &block)
wrap_data key.to_sym, @data.fetch(key, default, &block)
end
|
#respond_to_missing?(name) ⇒ Boolean
19
20
21
|
# File 'middleman-core/lib/middleman-core/core_extensions/data/proxies/hash.rb', line 19
def respond_to_missing?(name, *)
@data.key?(name) || super
end
|