Class: Stubborn::ProxyForModule

Inherits:
ProxyForInstance show all
Defined in:
lib/stubborn/proxy_for_module.rb

Instance Method Summary collapse

Methods inherited from ProxyForInstance

#class, #method_missing

Constructor Details

#initialize(proxy_target, options = {}) ⇒ ProxyForModule

Returns a new instance of ProxyForModule.



3
4
5
6
# File 'lib/stubborn/proxy_for_module.rb', line 3

def initialize(proxy_target, options = {})
  super
  redefine_const(proxy_target, self) unless proxy_target.name.strip.empty?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stubborn::ProxyForInstance

Instance Method Details

#nameObject



8
9
10
# File 'lib/stubborn/proxy_for_module.rb', line 8

def name
  @proxy_target.name
end

#new(*args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/stubborn/proxy_for_module.rb', line 12

def new(*args, &block)
  new_instance = @proxy_target.new(*args, &block)
  raise_missed_stub_exception("new", args, new_instance) if @only_methods.include?("new") && !@methods_to_skip.include?("new")
  options = {:class => self}

  if @instance_methods
    options[:only] = @instance_methods[:only]
    options[:except] = @instance_methods[:except]
  end

  ProxyForInstance.new(new_instance, options)
end