-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 15.09.2010 20:59, schrieb Gene Angelo:
> 
> Is there a way to access super from a yield block?

None I'm aware of. However, with a heavy bit of metaprogramming,
everything's possible in Ruby:

- -------------------------------------
class A

  def foo
    puts "foo in A"
  end

end

class B < A

  def foo(&block)
    puts "foo in B"
    if block_given?
      super_method = A.instance_method(:foo)
      instance_exec(super_method, &block)
    end
  end

end

x = B.new
x.foo do |super_method|
  m = super_method.bind(self)
  m.call
end
x.foo
- -------------------------------------

Outputs:

foo in B
foo in A
foo in B

ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

Note that I'd NEVER use such a construct in production code. But it's
fun to try what's possible in Ruby. ;-)

Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyRJeMACgkQDYShvwAbcNlfDwCfTBjFhdahiK3gsZWsIP6vmI1w
vaIAn07uvcYdXVjnDw39Az+X7cYCuwQR
=yDm7
-----END PGP SIGNATURE-----