Class: Hyperion::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion/aux/util.rb

Class Method Summary collapse

Class Method Details

.guard_param(value, what, expected_type = nil, &pred) ⇒ Object



13
14
15
16
# File 'lib/hyperion/aux/util.rb', line 13

def self.guard_param(value, what, expected_type=nil, &pred)
  pred ||= proc { |x| x.is_a?(expected_type) }
  pred.call(value) or fail BugError, "You passed me #{value.inspect}, which is not #{what}"
end

.nil_if_errorObject



5
6
7
8
9
10
11
# File 'lib/hyperion/aux/util.rb', line 5

def self.nil_if_error
  begin
    yield
  rescue StandardError
    return nil
  end
end