class Middleman::CoreExtensions::Data::Proxies::ArrayProxy

def fetch(index, default = (_missing_default = true), &block)

def fetch(index, default = (_missing_default = true), &block)
  wrap_data index, @data.fetch(index, default, &block)
end

def first(length = (missing_length = true))

def first(length = (missing_length = true))
  if missing_length || length == 1
    slice(0)
  else
    slice(0, length)
  end
end

def last(length = (missing_length = true))

def last(length = (missing_length = true))
  if missing_length || length == 1
    slice(-1)
  else
    slice(size - length, length)
  end
end

def method_missing(name, *args, &block)

def method_missing(name, *args, &block)
  if self.class.const_get(:WRAPPED_LIST_METHODS).include?(name)
    log_access(:__full_access__)
    return wrapped_array.send(name, *args, &block)
  end
  super
end

def respond_to_missing?(name, *)

def respond_to_missing?(name, *)
  self.class.const_get(:WRAPPED_LIST_METHODS).include?(name) || super
end

def slice(arg, length = (missing_length = true))

def slice(arg, length = (missing_length = true))
  if missing_length
    if arg.is_a?(Range)
      log_access(:__full_access__)
      @data.slice(arg)
    else
      relative_index = (@data.size + arg) % @data.size
      wrap_data(relative_index, @data[relative_index])
    end
  else
    log_access(:__full_access__)
    @data.slice(arg, length)
  end
end

def wrapped_array

def wrapped_array
  @wrapped_array ||= begin
    i = 0
    @data.map do |d|
      wrap_data(i, d).tap { i += 1 }
    end
  end
end