From 7603f4c0902bf5845c7e7654c3745f5519347c8b Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Mon, 27 Feb 2012 11:37:06 +0100 Subject: use instance_eval instead of yield self. - simplify and highlights initialization code - but shadows external scope variables --- lib/efl/ecore_evas.rb | 4 ++-- lib/efl/evas.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/efl/ecore_evas.rb b/lib/efl/ecore_evas.rb index d5e01b0..a2043a1 100644 --- a/lib/efl/ecore_evas.rb +++ b/lib/efl/ecore_evas.rb @@ -19,7 +19,7 @@ module Efl class REcoreEvas include Efl::ClassHelper search_prefixes 'ecore_evas_' - def initialize o=nil + def initialize o=nil, &block @ptr = ( case o when NilClass @@ -32,7 +32,7 @@ module Efl raise ArgumentError.new "wrong argument #{o.class.name}" end ) - yield self if block_given? + instance_eval &block if block end def self.release p Native.ecore_evas_free p diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb index 613b72b..e65a710 100644 --- a/lib/efl/evas.rb +++ b/lib/efl/evas.rb @@ -58,7 +58,7 @@ module Efl include Efl::ClassHelper search_prefixes 'evas_' # - def initialize o=nil + def initialize o=nil, &block @ptr = ( case o when NilClass @@ -69,7 +69,7 @@ module Efl raise ArgumentError.new "wrong argument #{o.class.name}" end ) - yield self if block_given? + instance_eval &block if block end def self.release p Native.evas_free p @@ -133,7 +133,7 @@ module Efl include Efl::ClassHelper search_prefixes 'evas_object_', 'evas_' # - def initialize a, *args + def initialize a, *args, &block @ptr = ( case a when FFI::Pointer @@ -144,7 +144,7 @@ module Efl raise ArgumentError.new "wrong argument #{a.class.name}" end ) - yield self if block_given? + instance_eval &block if block end def self.release p Native.evas_object_del p unless p.nil? @@ -161,9 +161,9 @@ module Efl REvasObject.release @ptr @ptr=nil end - def object_box_add + def object_box_add &block o = Evas::REvasBox.new FFI::AutoPointer.new Native.evas_object_box_add_to(@ptr), REvasObject.method(:release) - yield o if block_given? + o.instance_eval &block if block o end def evas_name -- cgit v1.2.3