Sha256: 6d5457e765098c8237a0c01ed07bc0e8210462250b851384bfa1217fb723146c

Contents?: true

Size: 408 Bytes

Versions: 7

Compression:

Stored size: 408 Bytes

Contents

require 'hyperion/aux/bug_error'

class Hyperion
  class Util
    def self.nil_if_error
      begin
        yield
      rescue StandardError
        return nil
      end
    end

    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyperion_http-0.1.8 lib/hyperion/aux/util.rb
hyperion_http-0.1.7 lib/hyperion/aux/util.rb
hyperion_http-0.1.6 lib/hyperion/aux/util.rb
hyperion_http-0.1.5 lib/hyperion/aux/util.rb
hyperion_http-0.1.4 lib/hyperion/aux/util.rb
hyperion_http-0.1.3 lib/hyperion/aux/util.rb
hyperion_http-0.1.2 lib/hyperion/aux/util.rb