Class: MimeActor::Dispatcher::InstanceExec

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, *args) ⇒ InstanceExec

Returns a new instance of InstanceExec.



38
39
40
41
42
# File 'lib/mime_actor/dispatcher.rb', line 38

def initialize(block, *args)
  @block = block
  @args = args
  validate!
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



36
37
38
# File 'lib/mime_actor/dispatcher.rb', line 36

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



36
37
38
# File 'lib/mime_actor/dispatcher.rb', line 36

def block
  @block
end

Instance Method Details

#call(target) ⇒ Object



44
45
46
47
# File 'lib/mime_actor/dispatcher.rb', line 44

def call(target)
  filtered_args = block.arity.negative? ? args : args.take(block.arity)
  target.instance_exec(*filtered_args, &block)
end