Class: Cleon::ArGuard
- Inherits:
-
Object
- Object
- Cleon::ArGuard
- Defined in:
- lib/cleon/basics/arguard.rb
Overview
The factory for guarding argument values
Class Method Summary collapse
Class Method Details
.new(name, message, block) ⇒ ArGuard
27 28 29 30 31 32 33 34 |
# File 'lib/cleon/basics/arguard.rb', line 27 def self.new(name, , block) Class.new do define_singleton_method "call" do |val, aname = name, = | return val if block.call(val) raise ArgumentError, ":#{aname} #{}", caller[0..-1] end end end |