Module: Kernel
- Defined in:
- lib/patch/let.rb,
lib/patch/enum.rb,
lib/patch/foobar.rb,
lib/patch/lambda.rb
Defined Under Namespace
Modules: Enum Classes: Lambda, Maplet
Class Method Summary collapse
-
.let(*args, &block) ⇒ Object
A convenient shorthand for ‘Maplet.new.define!(…)`.
Instance Method Summary collapse
-
#parry(klass, message = nil) ⇒ Object
Executes the given block and “parries” any caught StandardError, re-raising it as the specified klass with an optional custom message.
Class Method Details
.let(*args, &block) ⇒ Object
A convenient shorthand for ‘Maplet.new.define!(…)`.
116 117 118 |
# File 'lib/patch/let.rb', line 116 def let(*args, &block) Maplet.new.define!(*args, &block) end |
Instance Method Details
#parry(klass, message = nil) ⇒ Object
Executes the given block and “parries” any caught StandardError, re-raising it as the specified klass with an optional custom message.
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/patch/foobar.rb', line 350 def parry(klass, = nil) begin yield rescue StandardError => e = || e. if e.is_a?(klass) && .nil? raise e else new_error = klass.new() new_error.set_backtrace(e.backtrace) raise new_error end end end |