Sha256: fe92a73e67956f78af1fdda9b44a9e3a2af2b0f9b85b337532fdb1ad50b0d512

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

require 'wrap' 
 

class C 
  include Wrap 
 
  class << self 
    def method_missing(method, *args, &block) 
      case method.to_s 
        when %r/\A(before|after)_(.*)\Z/ 
          lifecycle, method = $1, $2 
          send(lifecycle, method, *args, &block) 
        else 
          super 
      end 
    end 
  end 
 
  before_initialize do 
    p :before_initialize 
  end

  after_initialize do 
    p :after_initialize 
  end
end

C.new

__END__
class C 
  include Wrap 
 
  class << self 
    def method_missing(method, *args, &block) 
p :method => method, :args => args
puts
      case method.to_s 
        when %r/\A(before|after)_(.*)\Z/ 
          lifecycle, method = $1, $2 
          wrap(method) 
          send(lifecycle, method, *args, &block) 
        else 
          super 
      end 
    end 
  end 
 
  before_initialize do 
    p :before_initialize 
  end

  after_initialize do 
    p :after_initialize 
  end
end

C.new

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wrap-1.5.0 b.rb