diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-05 09:35:27 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-05-05 09:35:27 +0200 |
commit | 88f4d1c3b0c9d5104be826e52ca7d3ced7b3e3c9 (patch) | |
tree | 55e7da94dd3d6f1cc6ef2fe0ad3a39edf0003424 /lib/efl/ffi.rb | |
parent | 67da13a4f7ddfad59c70df26e85152543c43c22f (diff) | |
download | ffi-efl-88f4d1c3b0c9d5104be826e52ca7d3ced7b3e3c9.zip ffi-efl-88f4d1c3b0c9d5104be826e52ca7d3ced7b3e3c9.tar.gz |
method_missing resolves m+'_get' + specs
Diffstat (limited to 'lib/efl/ffi.rb')
-rw-r--r-- | lib/efl/ffi.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/efl/ffi.rb b/lib/efl/ffi.rb index 0f8e8e9..35ba31c 100644 --- a/lib/efl/ffi.rb +++ b/lib/efl/ffi.rb @@ -97,11 +97,21 @@ module Efl end self.class.search_prefixes.each do |p| sym = p+m_s - if Efl::Native.respond_to? sym - self.class.class_eval "def #{m} *args, █ r=#{Efl::Native.name}.#{sym}(@ptr,#{args_s}); yield r if block_given?; r; end" - return self.send m, *args, &block - elsif Efl::Native.respond_to? m - self.class.class_eval "def #{m} *args, █ r=#{Efl::Native.name}.#{m}(@ptr,#{args_s}); yield r if block_given?; r; end" + meth = ( + if Efl::Native.respond_to? sym + sym + elsif Efl::Native.respond_to? m + m + elsif Efl::Native.respond_to? sym+'_get' + sym+'_get' + elsif Efl::Native.respond_to? m+'_get' + m+'_get' + else + nil + end + ) + if not meth.nil? + self.class.class_eval "def #{m} *args, █ r=Efl::Native.#{meth}(@ptr,#{args_s}); yield r if block_given?; r; end" return self.send m, *args, &block end end |