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



517
518
519
# File 'lib/hookr.rb', line 517

def handle
  @handle
end

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



517
518
519
# File 'lib/hookr.rb', line 517

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.



523
524
525
526
527
528
# File 'lib/hookr.rb', line 523

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

#call(*args) ⇒ Object

Must be overridden in subclass

Raises:

  • (NotImplementedError)


531
532
533
# File 'lib/hookr.rb', line 531

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