Module: GirFFI::ModuleBase

Defined in:
lib/gir_ffi/module_base.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments, &block) ⇒ Object



3
4
5
6
7
# File 'lib/gir_ffi/module_base.rb', line 3

def method_missing method, *arguments, &block
  result = setup_method method.to_s
  return super unless result
  self.send method, *arguments, &block
end

Instance Method Details

#const_missing(classname) ⇒ Object



9
10
11
# File 'lib/gir_ffi/module_base.rb', line 9

def const_missing classname
  load_class(classname) || super
end

#gir_ffi_builderObject



18
19
20
# File 'lib/gir_ffi/module_base.rb', line 18

def gir_ffi_builder
  self.const_get :GIR_FFI_BUILDER
end

#load_class(classname) ⇒ Object

TODO: Rename to setup_class to match setup and setup_method.



14
15
16
# File 'lib/gir_ffi/module_base.rb', line 14

def load_class classname
  gir_ffi_builder.build_namespaced_class classname.to_s
end

#setup_method(name) ⇒ Object



22
23
24
# File 'lib/gir_ffi/module_base.rb', line 22

def setup_method name
  gir_ffi_builder.setup_method name
end