Class: Neo4j::Driver::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/neo4j-ruby-driver_loader.rb

Class Method Summary collapse

Class Method Details

.jruby?Boolean

Returns:

  • (Boolean)


41
# File 'lib/neo4j-ruby-driver_loader.rb', line 41

def jruby? = @impl == :jruby

.load(impl) {|loader| ... } ⇒ Object

__dir__ resolves to:

dev:           lib/shared  → shared_root = lib/shared
installed gem: lib         → shared_root = lib (the impl dir is
                                  merged in by the staged build, so
                                  impl_root below is missing and the
                                  conditional push is skipped)

Yields:

  • (loader)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/neo4j-ruby-driver_loader.rb', line 19

def load(impl)
  @impl = impl
  shared_root = File.expand_path(__dir__)
  impl_root = File.expand_path("../#{impl}", shared_root)

  loader = Zeitwerk::Loader.new
  loader.tag = 'neo4j-ruby-driver'
  loader.inflector = Zeitwerk::GemInflector.new(File.expand_path('neo4j/driver', __dir__))
  loader.inflector.inflect('packstream' => 'PackStream', 'uuid' => 'UUID')
  loader.push_dir(shared_root)
  loader.push_dir(impl_root) if File.directory?(impl_root)
  yield loader if block_given?
  # ignore the Bundler.require-friendly entry files (neo4j-ruby-driver.rb, neo4j-ruby-driver_loader.rb,
  # neo4j_ruby_driver.rb) since Zeitwerk would otherwise try to
  # autoload them as constants with the wrong names.
  loader.ignore(File.expand_path(__FILE__))
  loader.ignore(File.expand_path('neo4j-ruby-driver.rb', __dir__))
  loader.ignore(File.expand_path('neo4j_ruby_driver.rb', __dir__))
  loader.setup
  loader.eager_load
end

.mri?Boolean

Returns:

  • (Boolean)


43
# File 'lib/neo4j-ruby-driver_loader.rb', line 43

def mri? = @impl == :mri