Class: CurrentFu::Object

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_owner) ⇒ Object

Returns a new instance of Object.



4
5
6
# File 'lib/current_fu/object.rb', line 4

def initialize(current_owner)
  @current_owner = current_owner
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (protected)



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/current_fu/object.rb', line 39

def method_missing(method, *args)
  if current_owner_respond_to?(method)
    if block_given?
      @current_owner.send(current_method(method),*args) { |*block_args| yield(*block_args) }
    else
      @current_owner.send(current_method(method),*args)
    end
  else
    block_given? ? super { |*block_args| yield(*block_args) } : super
  end
end

Class Method Details

.instanceObject



10
11
12
# File 'lib/current_fu/object.rb', line 10

def instance
  Thread.current[:current_fu_instance]
end

.instance=(current_instance) ⇒ Object



14
15
16
# File 'lib/current_fu/object.rb', line 14

def instance=(current_instance)
  Thread.current[:current_fu_instance] = current_instance
end

Instance Method Details

#instanceObject



20
21
22
# File 'lib/current_fu/object.rb', line 20

def instance
  @current_owner
end

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/current_fu/object.rb', line 24

def respond_to?(method)
  current_owner_respond_to?(method) || super
end