Class: Proxify::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/proxify/proxify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, proxies) ⇒ Proxy

Returns a new instance of Proxy.



7
8
9
10
# File 'lib/proxify/proxify.rb', line 7

def initialize(subject, proxies)
  @subject = subject
  @proxies = proxies
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/proxify/proxify.rb', line 12

def method_missing(method, *args, &block)
  if proxies.include?(method)
    return subject.send(method, *args, &block)
  else
    raise NoMethodError, method.to_s
  end
end

Instance Attribute Details

#proxiesObject (readonly)

Returns the value of attribute proxies.



5
6
7
# File 'lib/proxify/proxify.rb', line 5

def proxies
  @proxies
end

#subjectObject (readonly)

Returns the value of attribute subject.



5
6
7
# File 'lib/proxify/proxify.rb', line 5

def subject
  @subject
end