Class: Prototype

Inherits:
Object show all
Defined in:
lib/alib-0.5.1/prototype.rb,
lib/alib-0.5.1/prototype-0.3.0.rb

Overview

Defined Under Namespace

Modules: Prototypical

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.new(parent = Object, *a, &b) ⇒ Object Also known as: exnihilo, ex_nihilo



165
166
167
168
169
170
171
172
173
174
# File 'lib/alib-0.5.1/prototype.rb', line 165

def new parent = Object, *a, &b
  parent = parent.class unless Class === parent
  c = Class.new parent
  c.extend Prototypical
  c.__prototype_table__.update parent.__prototype_table__ if
    parent.respond_to? '__prototype_table__'
  c.__prototype_prototype__ &b
  obj = c.new *a 
  obj
end

.prototyping(obj, *a, &b) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/alib-0.5.1/prototype.rb', line 179

def prototyping obj, *a, &b
  c =
    class << obj 
      self
    end
  parent = c.class
  c.extend Prototypical unless Prototypical === c
  c.__prototype_table__.update parent.__prototype_table__ if
    parent.respond_to? '__prototype_table__'
  c.__prototype_prototype__ &b
  obj.__prototype_init__ c
  obj
end