Class: ActiveRecord::Futures::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/futures/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Proxy

Returns a new instance of Proxy.



6
7
8
# File 'lib/active_record/futures/proxy.rb', line 6

def initialize(obj)
  @proxied = obj
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



24
25
26
27
28
29
30
# File 'lib/active_record/futures/proxy.rb', line 24

def method_missing(method, *args, &block)
  if @proxied.respond_to?(method)
    @proxied.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#proxiedObject (readonly)

Returns the value of attribute proxied.



4
5
6
# File 'lib/active_record/futures/proxy.rb', line 4

def proxied
  @proxied
end

Instance Method Details

#!=(other) ⇒ Object



19
20
21
22
# File 'lib/active_record/futures/proxy.rb', line 19

def !=(other)
  other = other.proxied if other.is_a? self.class
  @proxied != other
end

#==(other) ⇒ Object



14
15
16
17
# File 'lib/active_record/futures/proxy.rb', line 14

def ==(other)
  other = other.proxied if other.is_a? self.class
  @proxied == other
end

#proxy?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/active_record/futures/proxy.rb', line 10

def proxy?
  true
end

#respond_to?(method, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/active_record/futures/proxy.rb', line 32

def respond_to?(method, include_all = false)
  method.to_sym == :proxy? || super || @proxied.respond_to?(method, include_all)
end