Class: Proxies::ArrayProxy

Inherits:
Base
  • Object
show all
Defined in:
lib/bzproxies/array_proxy.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #proxies

Instance Method Summary collapse

Methods inherited from Base

#==, #__getobj__, #__setobj__, const_missing, #eql?, #method_missing, #proxy?, #respond_to?

Methods included from Stub

#__getobj__, #proxy?, #stub?

Constructor Details

#initialize(*args) ⇒ ArrayProxy

Returns a new instance of ArrayProxy.

Raises:

  • (::ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bzproxies/array_proxy.rb', line 5

def initialize *args
  super
  raise ::ArgumentError, "expected Array, given #{@target.class}" unless @target.kind_of? ::Array
  unless @proxies.empty? || @target.nil?
    proxy = @proxies.first
    @target = @target.map do |i|
      unless i.respond_to? :stub?
        proxy.new i, :proxies => @proxies[1..-1], :options => @options
      else
        i
      end
    end        
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Proxies::Base