Class: RubyExt::CallbacksProxy

Inherits:
BasicObject
Defined in:
lib/ruby_ext/more/callbacks_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, callback_name) ⇒ CallbacksProxy

Returns a new instance of CallbacksProxy.



4
5
6
# File 'lib/ruby_ext/more/callbacks_proxy.rb', line 4

def initialize object, callback_name
  @object, @callback_name = object, callback_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (protected)



16
17
18
19
20
# File 'lib/ruby_ext/more/callbacks_proxy.rb', line 16

def method_missing m, *args, &block
  object.run_callbacks @callback_name, m do
    object.public_send m, *args, &block
  end
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



2
3
4
# File 'lib/ruby_ext/more/callbacks_proxy.rb', line 2

def object
  @object
end

Instance Method Details

#callback_proxy?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/ruby_ext/more/callbacks_proxy.rb', line 8

def callback_proxy?
  true
end