Sha256: 309673fcd4bf07f126ec79a225e68748ab80b5f2412623d5d3ca9a712bec1c5c

Contents?: true

Size: 413 Bytes

Versions: 1

Compression:

Stored size: 413 Bytes

Contents

# redef is a super simple way to robustly override methods - providing the
# POLS method of referring to the previous method as (wait for it) super.
# it's really that simple
#
  require 'redef'

  class C
    def foo() 30 end

    p C.new.foo  #=> 30

    redef do 
      def foo() super + 2 end
    end

    p C.new.foo #=> 32

    redef do 
      def foo() super + 10 end
    end

    p C.new.foo #=> 42
  end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redef-0.4.2 samples/a.rb