Class: HookR::Callback

Inherits:
Struct
  • Object
show all
Includes:
Comparable, FailFast::Assertions
Defined in:
lib/hookr.rb

Direct Known Subclasses

BlockCallback, MethodCallback

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handleObject

Returns the value of attribute handle

Returns:

  • (Object)

    the current value of handle



539
540
541
# File 'lib/hookr.rb', line 539

def handle
  @handle
end

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



539
540
541
# File 'lib/hookr.rb', line 539

def index
  @index
end

Instance Method Details

#<=>(other) ⇒ Object

Callbacks with the same handle are always equal, which prevents duplicate handles in CallbackSets. Otherwise, callbacks are sorted by index.



545
546
547
548
549
550
# File 'lib/hookr.rb', line 545

def <=>(other)
  if handle == other.handle
    return 0
  end
  self.index <=> other.index
end

#call(*args) ⇒ Object

Must be overridden in subclass

Raises:

  • (NotImplementedError)


553
554
555
# File 'lib/hookr.rb', line 553

def call(*args)
  raise NotImplementedError, "Callback is an abstract class"
end