Class: Class

Inherits:
Object show all
Defined in:
lib/carat/init.rb,
lib/carat-dev/vars/vars.rb

Overview

Init

Allows you to use #init inplace of #initialize. It does this by aliasing initialize to init when it is defined.

Synopsis

require 'carat/init'

class T
  def init
    puts "Here"
  end
end

t = T.new   #=> "Here"

Author(s)

  • Thaoms Sawyer

Instance Method Summary collapse

Instance Method Details

#method_added(meth) ⇒ Object



28
29
30
31
32
# File 'lib/carat/init.rb', line 28

def method_added( meth )
  if meth == :init
    self.class_eval { alias initialize init }
  end
end

#new(*args, &block) ⇒ Object



42
43
44
45
46
# File 'lib/carat-dev/vars/vars.rb', line 42

def new(*args, &block)
  o = new_orig(*args, &block)
  o.instance_variable_set('@iv',{})
  o
end

#new_origObject



41
# File 'lib/carat-dev/vars/vars.rb', line 41

alias_method :new_orig, :new