1
0
Fork 0
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:
Thomas Reynolds 2018-12-27 12:55:04 -08:00
parent 46c3e8cbeb
commit 57268a1e8f
3 changed files with 7 additions and 6 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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