mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Pass all known methods through proxy. For #2228
This commit is contained in:
parent
46c3e8cbeb
commit
57268a1e8f
3 changed files with 7 additions and 6 deletions
|
@ -6,8 +6,7 @@ module Middleman
|
|||
module Data
|
||||
module Proxies
|
||||
class ArrayProxy < BaseProxy
|
||||
FULL_ACCESS_METHODS = Set.new %i[size any? inspect join]
|
||||
WRAPPED_LIST_METHODS = Set.new %i[each select sort shuffle reverse]
|
||||
WRAPPED_LIST_METHODS = Set.new %i[each each_with_index select sort shuffle reverse]
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
if self.class.const_get(:WRAPPED_LIST_METHODS).include?(name)
|
||||
|
|
|
@ -16,7 +16,7 @@ module Middleman
|
|||
end
|
||||
|
||||
def method_missing(name, *args, &block)
|
||||
if self.class.const_get(:FULL_ACCESS_METHODS).include?(name)
|
||||
if @data.respond_to?(name)
|
||||
log_access(:__full_access__)
|
||||
|
||||
return @data.send(name, *args, &block)
|
||||
|
|
|
@ -5,8 +5,6 @@ module Middleman
|
|||
module Data
|
||||
module Proxies
|
||||
class HashProxy < BaseProxy
|
||||
FULL_ACCESS_METHODS = Set.new %i[size inspect keys key? values each_key]
|
||||
|
||||
def fetch(key, default = Undefined, &block)
|
||||
wrap_data key.to_sym, @data.fetch(key, default, &block)
|
||||
end
|
||||
|
@ -17,7 +15,11 @@ module Middleman
|
|||
alias get []
|
||||
|
||||
def method_missing(name, *_args)
|
||||
self[name] if @data.key?(name)
|
||||
return self[name] if @data.key?(name)
|
||||
|
||||
super
|
||||
rescue NoMethodError
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue