Class: Hookem::HookCallable

Inherits:
Struct
  • Object
show all
Defined in:
lib/hookem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HookCallable

Returns a new instance of HookCallable.



5
6
7
8
9
# File 'lib/hookem.rb', line 5

def initialize(hash)
  super(*hash.values_at(*self.class.members.map(&:to_sym)) )
  self.preargs    ||= []
  self.identifier ||= self.__id__
end

Instance Attribute Details

#callableObject

Returns the value of attribute callable

Returns:

  • (Object)

    the current value of callable



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

def callable
  @callable
end

#eventloopObject

Returns the value of attribute eventloop

Returns:

  • (Object)

    the current value of eventloop



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

def eventloop
  @eventloop
end

#identifierObject

Returns the value of attribute identifier

Returns:

  • (Object)

    the current value of identifier



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

def identifier
  @identifier
end

#preargsObject

Returns the value of attribute preargs

Returns:

  • (Object)

    the current value of preargs



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

def preargs
  @preargs
end

Instance Method Details

#call(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/hookem.rb', line 11

def call(*args)
  if eventloop
    eventloop.enqueue do
      _execute(*args)
    end
  else
    _execute(*args)
  end
end