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) ⇒ Object

Raises:

  • (ArgumentError)


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

def self.require_non_nil!(obj, message)
  raise ArgumentError, "#{message} can't be nil" if obj.nil?
end

.require_non_nil_credentials!(username, password) ⇒ Object



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

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