Class: Mato::Rescue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filter, on_error:) ⇒ Rescue

Returns a new instance of Rescue.



8
9
10
11
# File 'lib/mato/rescue.rb', line 8

def initialize(filter, on_error:)
  @filter = filter
  @on_error = on_error
end

Instance Attribute Details

#filterObject (readonly)

Returns the value of attribute filter.



5
6
7
# File 'lib/mato/rescue.rb', line 5

def filter
  @filter
end

#on_errorObject (readonly)

Returns the value of attribute on_error.



6
7
8
# File 'lib/mato/rescue.rb', line 6

def on_error
  @on_error
end

Instance Method Details

#call(content) ⇒ Object



13
14
15
16
17
18
# File 'lib/mato/rescue.rb', line 13

def call(content)
  filter.call(content)
rescue => e
  on_error.call(e)
  content
end