A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://rubydoc.info/github/piotrmurach/github/master/Github/Validations/Presence below:

Presence – Documentation for piotrmurach/github (master) – RubyDoc.info

Module: Github::Validations::Presence Overview

A mixin to help validate presence of non-empty values

Instance Method Summary collapse Instance Method Details #assert_presence_of(*args) ⇒ Object

Ensure that essential arguments are present before request is made.

Parameters
Hash/Array of arguments to be checked against nil and empty string
Example
assert_presence_of user: '...', repo: '...'
assert_presence_of user, repo
19
20
21
22
23
24
25
26
27
28
# File 'lib/github_api/validations/presence.rb', line 19

def assert_presence_of(*args)
  hash = args.last.is_a?(::Hash) ? args.pop : {}

  errors = hash.select { |key, val| val.to_s.empty? }
  raise Github::Error::Validations.new(errors) unless errors.empty?

  args.each do |arg|
    raise ArgumentError, "parameter cannot be nil" if arg.nil?
  end
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4