Class: GirFFI::MethodStubber

Inherits:
Object
  • Object
show all
Defined in:
lib/gir_ffi/method_stubber.rb

Overview

Generates method stubs that will replace themselves with the real method upon being called.

Instance Method Summary collapse

Constructor Details

#initialize(method_info) ⇒ MethodStubber

Returns a new instance of MethodStubber.



5
6
7
# File 'lib/gir_ffi/method_stubber.rb', line 5

def initialize method_info
  @info = method_info
end

Instance Method Details

#method_stubObject



9
10
11
12
13
14
15
# File 'lib/gir_ffi/method_stubber.rb', line 9

def method_stub
  "def \#{@info.method? ? '' : 'self.'}\#{@info.safe_name} *args, &block\nsetup_and_call \#{@info.name.to_sym.inspect}, *args, &block\nend\n".reset_indentation
end