Module: Neo4j::Driver::Internal::Validator

Defined in:
lib/neo4j/driver/internal/validator.rb

Class Method Summary collapse

Class Method Details

.require_hash!(obj) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
# File 'lib/neo4j/driver/internal/validator.rb', line 13

def self.require_hash!(obj)
  raise(ArgumentError, yield) unless obj.nil? || obj.is_a?(Hash)
end

.require_hash_parameters!(parameters) ⇒ Object



7
8
9
10
11
# File 'lib/neo4j/driver/internal/validator.rb', line 7

def self.require_hash_parameters!(parameters)
  require_hash!(parameters) do
    "The parameters should be provided as Map type. Unsupported parameters type: #{parameters.class.name}"
  end
end

.require_non_nil!(obj, message = nil) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
# File 'lib/neo4j/driver/internal/validator.rb', line 17

def self.require_non_nil!(obj, message = nil)
  raise ArgumentError, [message, "can't be nil"].compact.join(' ') if obj.nil?
  obj
end

.require_non_nil_credentials!(username, password) ⇒ Object



22
23
24
25
# File 'lib/neo4j/driver/internal/validator.rb', line 22

def self.require_non_nil_credentials!(username, password)
  require_non_nil! username, "Username"
  require_non_nil! password, "Password"
end