Class: Wee::LiteralMethodCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/wee/core/callback.rb

Overview

A serializable callback.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, method_id = :call, *args) ⇒ LiteralMethodCallback

Returns a new instance of LiteralMethodCallback.



109
110
111
112
# File 'lib/wee/core/callback.rb', line 109

def initialize(obj, method_id=:call, *args)
  @obj, @method_id = obj, method_id
  @args = args unless args.empty?
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



107
108
109
# File 'lib/wee/core/callback.rb', line 107

def obj
  @obj
end

Instance Method Details

#call(*args) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/wee/core/callback.rb', line 114

def call(*args)
  if @args
    @obj.send(@method_id, *(@args+args))
  else
    @obj.send(@method_id, *args)
  end
end