Class: WipeOut::Callback

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, block) ⇒ Callback

Returns a new instance of Callback.



5
6
7
8
# File 'lib/wipe_out/callback.rb', line 5

def initialize(name, block)
  @name = name.to_sym
  @block = block
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/wipe_out/callback.rb', line 3

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
# File 'lib/wipe_out/callback.rb', line 16

def ==(other)
  name == other.name &&
    block == other.block
end

#run(execution) ⇒ Object



10
11
12
13
14
# File 'lib/wipe_out/callback.rb', line 10

def run(execution)
  raise("Wrong arity for callback name=#{name}") if block.arity != 1

  block.call(execution)
end