Class: Rugl::Backends::PrefixedModuleAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/rugl/backends/opengl_bindings.rb

Direct Known Subclasses

OpenGLBindingsGL, OpenGLBindingsGLFW

Instance Method Summary collapse

Constructor Details

#initialize(target:, method_prefix:, constant_prefix:) ⇒ PrefixedModuleAdapter

Returns a new instance of PrefixedModuleAdapter.



8
9
10
11
12
# File 'lib/rugl/backends/opengl_bindings.rb', line 8

def initialize(target:, method_prefix:, constant_prefix:)
  @target = target
  @method_prefix = method_prefix.to_s
  @constant_prefix = constant_prefix.to_s
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



18
19
20
21
22
23
# File 'lib/rugl/backends/opengl_bindings.rb', line 18

def method_missing(name, *args, &block)
  method_name = resolve_method_name(name, include_private: true)
  return @target.public_send(method_name, *args, &block) if method_name

  super
end

Instance Method Details

#const_defined?(name, inherit = true) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rugl/backends/opengl_bindings.rb', line 25

def const_defined?(name, inherit = true)
  !resolve_constant_name(name, inherit: inherit).nil?
end

#const_get(name, inherit = true) ⇒ Object

Raises:

  • (NameError)


29
30
31
32
33
34
# File 'lib/rugl/backends/opengl_bindings.rb', line 29

def const_get(name, inherit = true)
  constant_name = resolve_constant_name(name, inherit: inherit)
  return @target.const_get(constant_name, inherit) if constant_name

  raise NameError, "uninitialized constant #{name}"
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rugl/backends/opengl_bindings.rb', line 14

def respond_to_missing?(name, include_private = false)
  !resolve_method_name(name, include_private: include_private).nil? || super
end