Class: Because

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

Class Method Summary collapse

Class Method Details

.of(reason, &block) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/because.rb', line 4

def self.of(reason, &block)
  arr = (Thread.current[:because] ||= []) << reason
  begin
    block.call
  ensure
    arr.slice!(arr.length - 1)
  end
end